| 1 |
#ifndef INCLUDED_SEMANTIC_ |
| 2 |
#define INCLUDED_SEMANTIC_ |
| 3 |
|
| 4 |
#include <utility> |
| 5 |
#include <string> |
| 6 |
|
| 7 |
union Semantic |
| 8 |
{ |
| 9 |
friend std::ostream &operator<<(std::ostream &out, Semantic const &obj); |
| 10 |
|
| 11 |
std::pair<int, int> d_int; |
| 12 |
std::pair<int, std::string> d_str; |
| 13 |
|
| 14 |
public: |
| 15 |
enum Type |
| 16 |
{ |
| 17 |
INT, |
| 18 |
IDENTIFIER |
| 19 |
}; |
| 20 |
|
| 21 |
Semantic(); |
| 22 |
Semantic(Type type, char const *txt); |
| 23 |
Semantic(Semantic const &other); // 2 |
| 24 |
~Semantic(); |
| 25 |
|
| 26 |
Semantic &operator=(Semantic const &rhs); |
| 27 |
|
| 28 |
void swap(Semantic &other); |
| 29 |
}; |
| 30 |
|
| 31 |
inline Semantic::Semantic() |
| 32 |
: |
| 33 |
d_int {INT, 0} |
| 34 |
{} |
| 35 |
|
| 36 |
#endif |