stmtNode.h
Ir a la documentación de este archivo.
1 //stmtNode.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 //-------------------------------------------------------------------------------------------
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26  * MA 02110-1301, USA.
27  */
28 //-------------------------------------------------------------------------------------------
29 
30 //-------------------------------------------------------------------------------------------
39 //-------------------------------------------------------------------------------------------
40 
41 //-------------------------------------------------------------------------------------------
42 #ifndef _RUN_STMTS_STMTNODE_
43 #define _RUN_STMTS_STMTNODE_
44 
45 #include "../tree/runTree.h"
46 
47 #include "condStmtNode.h"
48 #include "ioStmtNode.h"
49 #include "loopStmtNode.h"
50 #include "../../lshParser.h"
51 
52 extern int yylineno;
53 extern int yyparse ();
54 extern void yyrestart(FILE*);
55 extern FILE* yyin;
56 extern string infile;
57 //-------------------------------------------------------------------------------------------
58 
59 //-------------------------------------------------------------------------------------------
66 class noNode :
67  public runNode {
68  public:
72  noNode ();
76  void run ();
77 };
78 //-------------------------------------------------------------------------------------------
79 
80 //-------------------------------------------------------------------------------------------
97 class stmtNode :public runNode {
98  public:
108  stmtNode (runNode* node1, runNode* node2, YYLTYPE bloq = YYLTYPE(), bool firstlevel = false);
115  void run ();
120  static void newLine (void);
124  static int row_;
128  static bool compile_error;
129  private:
130  runNode *node1_, *node2_;
131  int line_;
132  bool firstlevel_;
133 };
134 //-------------------------------------------------------------------------------------------
135 
136 //-------------------------------------------------------------------------------------------
144 class includeNode :
145  public runNode {
146  public:
151  includeNode (runNode* file);
157  void run ();
158  private:
159  runNode* file_;
160 };
161 //-------------------------------------------------------------------------------------------
162 
163 //-------------------------------------------------------------------------------------------
171 class typeofNode :
172  public runNode {
173  public:
178  typeofNode (idNode* id);
183  void run ();
189  static string type (runNode *r);
190  private:
191  idNode *id_;
192 };
193 //-------------------------------------------------------------------------------------------
194 
195 //-------------------------------------------------------------------------------------------
206  public std::exception {
207  public:
212  breakException (int n = 1);
218  const char* what() const throw();
223  void end ();
224  private:
225  int n_;
226 };
227 //-------------------------------------------------------------------------------------------
228 
229 //-------------------------------------------------------------------------------------------
241 class breakNode:
242  public runNode {
243  public:
248  breakNode (int n = 1);
253  void run ();
254  private:
255  int n_;
256 };
257 //-------------------------------------------------------------------------------------------
258 
259 //-------------------------------------------------------------------------------------------
266 class exitNode:
267  public runNode {
268  public:
273  void run ();
274 };
275 //-------------------------------------------------------------------------------------------
276 
277 //-------------------------------------------------------------------------------------------
290 class labelNode :
291  public runNode {
292  public:
298  labelNode (runNode* id, runNode* stmt);
303  void run ();
304  private:
305  runNode *id_, *stmt_;
306 };
307 //-------------------------------------------------------------------------------------------
308 
309 //-------------------------------------------------------------------------------------------
318  public std::exception {
319  public:
323  const char* what() const throw();
324 };
325 //-------------------------------------------------------------------------------------------
326 
327 //-------------------------------------------------------------------------------------------
337 class gotoNode :
338  public runNode {
339  public:
345  gotoNode (runNode* node);
352  void run ();
353  private:
354  runNode *node1_;
355 };
356 //-------------------------------------------------------------------------------------------
357 
358 //-------------------------------------------------------------------------------------------
371 class withNode : public runNode {
372  public:
378  withNode (runNode* node, runNode *stmts);
383  void run();
389  static void push_with (runNode* node);
394  static runNode *get_with ();
398  static void pop_with ();
399 
400  private:
401  static vector<runNode *> stack_with;
402  static int top_with;
403  runNode *node_, *stmts_;
404 };
405 //-------------------------------------------------------------------------------------------
406 
407 //-------------------------------------------------------------------------------------------
414 class sizeOfNode : public arithNode {
415  public:
420  sizeOfNode (runNode* node);
425  void run ();
426  private:
427  runNode * node_;
428 };
429 //-------------------------------------------------------------------------------------------
430 
431 //-------------------------------------------------------------------------------------------
440 class datInfoNode : public runNode {
441  public:
446  datInfoNode (runNode* node);
453  void run ();
454  private:
455  runNode * node_;
456 };
457 //-------------------------------------------------------------------------------------------
458 
459 //-------------------------------------------------------------------------------------------
473  public std::exception {
474  public:
479  throwException (runNode* resp);
483  const char* what() const throw();
488  runNode* val () const;
489  private:
490  runNode* resp_;
491 };
492 //-------------------------------------------------------------------------------------------
493 
494 //-------------------------------------------------------------------------------------------
504 class throwNode : public runNode {
505  public:
510  throwNode (runNode* obj);
516  void run ();
517  private:
518  runNode *obj_;
519 };
520 //-------------------------------------------------------------------------------------------
521 
522 //-------------------------------------------------------------------------------------------
534 class tryNode : public runNode {
535  public:
542  tryNode (runNode* tryblock, runNode *id, runNode *catchblock);
549  void run ();
550  private:
551  runNode * tryblock_, *id_, *catchblock_;
552 };
553 //-------------------------------------------------------------------------------------------
554 
555 //-------------------------------------------------------------------------------------------
556 #endif
557 //-------------------------------------------------------------------------------------------
558 //Fco. Javier Bohórquez Ogalla
Nodo identificador.
Definition: idNode.h:59
runNode * val() const
Definition: stmtNode.cpp:461
static bool compile_error
Definition: stmtNode.h:128
static void push_with(runNode *node)
Definition: stmtNode.cpp:369
static int row_
Definition: stmtNode.h:124
void run()
Definition: stmtNode.cpp:130
Nodo sentencia try...catch.
Definition: stmtNode.h:534
datInfoNode(runNode *node)
Definition: stmtNode.cpp:432
Nodos aritméticos.
Definition: expNode.h:351
Nodo de sentencia.
Definition: stmtNode.h:97
Nodo sentencia de finalización.
Definition: stmtNode.h:266
Nodos sentencias de entrada y salida.
includeNode(runNode *file)
Definition: stmtNode.cpp:128
Nodo lazar excepción.
Definition: stmtNode.h:504
tryNode(runNode *tryblock, runNode *id, runNode *catchblock)
Definition: stmtNode.cpp:486
void run()
Definition: stmtNode.cpp:274
const char * what() const
Definition: stmtNode.cpp:36
typeofNode(idNode *id)
Definition: stmtNode.cpp:163
sizeOfNode(runNode *node)
Definition: stmtNode.cpp:390
Nodo bloque en el contexto de un objeto.
Definition: stmtNode.h:371
Nodo ejecutable.
Definition: runTree.h:123
Nodo sentencia vacía.
Definition: stmtNode.h:66
Excepción de exepción lanzada.
Definition: stmtNode.h:472
breakNode(int n=1)
Definition: stmtNode.cpp:262
Excepción de salto a etiqueta.
Definition: stmtNode.h:317
Nodos sentencias iterativas.
void run()
Definition: stmtNode.cpp:470
Nodo información sobre dato.
Definition: stmtNode.h:440
void run()
Definition: stmtNode.cpp:165
withNode(runNode *node, runNode *stmts)
Definition: stmtNode.cpp:354
labelNode(runNode *id, runNode *stmt)
Definition: stmtNode.cpp:287
void run()
Definition: stmtNode.cpp:290
Nodo sentencia espacio de memoria.
Definition: stmtNode.h:414
void run()
Definition: stmtNode.cpp:327
static runNode * get_with()
Definition: stmtNode.cpp:374
Nodo impresión de tipo.
Definition: stmtNode.h:171
void run()
Definition: stmtNode.cpp:392
void run()
Definition: stmtNode.cpp:357
void run()
Definition: stmtNode.cpp:79
stmtNode(runNode *node1, runNode *node2, YYLTYPE bloq=YYLTYPE(), bool firstlevel=false)
Definition: stmtNode.cpp:49
void run()
Definition: stmtNode.cpp:495
Nodo de salto.
Definition: stmtNode.h:337
void run()
Definition: stmtNode.cpp:264
static void newLine(void)
Definition: stmtNode.cpp:118
gotoNode(runNode *node)
Definition: stmtNode.cpp:325
Nodo sentencia inclusión de fichero.
Definition: stmtNode.h:144
Excepción rotura de bloque.
Definition: stmtNode.h:205
Nodo sentencia rotura de bloque.
Definition: stmtNode.h:241
static string type(runNode *r)
Definition: stmtNode.cpp:206
const char * what() const
Definition: stmtNode.cpp:457
void run()
Definition: stmtNode.cpp:434
void run()
Definition: stmtNode.cpp:29
const char * what() const
Definition: stmtNode.cpp:318
throwException(runNode *resp)
Definition: stmtNode.cpp:455
breakException(int n=1)
Definition: stmtNode.cpp:34
static void pop_with()
Definition: stmtNode.cpp:380
noNode()
Definition: stmtNode.cpp:27
Nodos de sentencias condicionales.
void end()
Definition: stmtNode.cpp:40
throwNode(runNode *obj)
Definition: stmtNode.cpp:468
Nodo etiqueta.
Definition: stmtNode.h:290