-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrammarSymbol.H
39 lines (33 loc) · 936 Bytes
/
GrammarSymbol.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/****************************************************************
GrammarSymbol.H
This is open-source software, governed by the ARTISTIC LICENSE
(see www.opensource.org).
****************************************************************/
#ifndef INCL_GrammarSymbol_H
#define INCL_GrammarSymbol_H
#include <iostream>
#include "BOOM/String.H"
using namespace std;
using namespace BOOM;
enum SymbolType {
TERMINAL_SYMBOL,
NONTERMINAL_SYMBOL
};
class GrammarSymbol {
public:
GrammarSymbol(SymbolType,const BOOM::String &lexeme);
GrammarSymbol();
String &getLexeme();
SymbolType &getType();
bool isTerminal() const;
bool isNonterminal() const;
unsigned hash() const; // for use in BOOM::HashTable
bool operator==(const GrammarSymbol &);
void printOn(ostream &) const;
private:
BOOM::String lexeme;
SymbolType type;
};
ostream &operator<<(ostream &,const GrammarSymbol &);
#endif