symbols.h
Ir a la documentación de este archivo.
1 //symbols.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 //-------------------------------------------------------------------------------------------
35 //-------------------------------------------------------------------------------------------
36 #ifndef _RUN_TABLE_SYMBOLS_
37 #define _RUN_TABLE_SYMBOLS_
38 //-------------------------------------------------------------------------------------------
39 
40 //-------------------------------------------------------------------------------------------
41 #include <string>
42 #include <vector>
43 #include <iostream>
44 #include "../tree/runTree.h"
45 using namespace std;
46 //-------------------------------------------------------------------------------------------
47 
48 class isymTable;
49 //-------------------------------------------------------------------------------------------
65 class symbolsTable {
66  public:
70  symbolsTable ();
76  symbolsTable (const symbolsTable* table);
81  symbolsTable (symbolsTable* table);
87  refNode* &push_back (refNode* node);
91  void pop_back ();
98  static symbolsTable copyRef (symbolsTable *sym);
104  isymTable begin ();
110  isymTable end ();
116  isymTable begin () const;
122  isymTable end () const;
131  isymTable find (runNode* node);
141  refNode* findRef (runNode* node, runNode* default_node = NULL);
145  void clear ();
149  void clearRef ();
154  bool empty () ;
159  int size () const;
168  runNode* &operator[] (const string key);
176  runNode* findKey (string key) const;
185  runNode* &operator[] (refNode* key);
194  runNode* &operator[] (runNode* key);
203  runNode* &operator[] (int val);
210  refNode * &getRef (int val);
216  void erase (runNode* key);
222  void erase_position (unsigned int i);
226  void print ();
231  refNode* last ();
236  refNode* first ();
242  void insert (isymTable i, refNode * element);
248  void insert (int pos, refNode * element);
249  private:
250  int findPosition (refNode* node);
251  vector<refNode*> table_;
252 };
253 //-------------------------------------------------------------------------------------------
267 class isymTable {
268  public:
272  isymTable ();
279  isymTable (const symbolsTable* sym , unsigned int pos);
285  bool operator==(const isymTable &elem) const;
291  bool operator!=(const isymTable &elem) const;
297  isymTable& operator++();
303  isymTable& operator--();
309  isymTable operator++(int);
315  isymTable operator--(int);
320  unsigned int getPos ();
329  private:
330  void setPair ();
331  symbolsTable* sym_;
332  unsigned int pos_;
333 
334 };
335 //-------------------------------------------------------------------------------------------
336 typedef symbolsTable symbols;
337 typedef isymTable isym;
338 //-------------------------------------------------------------------------------------------
339 #endif
340 //-------------------------------------------------------------------------------------------
341 
342 //-------------------------------------------------------------------------------------------
343 //Fco. Javier Bohórquez Ogalla
344 
Tabla de símbolos.
Definition: symbols.h:65
Nodo ejecutable.
Definition: runTree.h:123
Iterador de tabla de símbolos.
Definition: symbols.h:267
refNode * first
Definition: symbols.h:324
Nodo referencia.
Definition: runTree.h:279
runNode * second
Definition: symbols.h:328