-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.h
42 lines (35 loc) · 1.48 KB
/
Token.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
39
40
41
42
#include <iostream>
#include <cstring>
#include <cctype>
#include "ArrayList.h"
#ifndef TOKEN_H
#define TOKEN_H
class Token
{
private:
char* cstr; // pointer to an array of characters storing the characters in this token
int frequency; // number of occurences of this token
ArrayList number_list; // list of line numbers associated with this token
public:
// constructors
Token(); // default constructor
explicit Token(const char* chars, int line_num); // normal constructor
Token(const Token& token); // copy constructor
Token(Token&& token); // move constructor
// assignment operators
Token& operator=(const Token& rhs); // copy assignment operator
Token& operator=(Token&& rhs); // move assignment operator
~Token(); // destructor
// getters
char *c_str() const;
const ArrayList& getNumberList() const;
int getFrequency() const;
// member functions
void addLineNumber(int line_num);
int size() const;
int compare(const Token& aToken) const;
void print(std::ostream &output) const;
// >> operator overload
friend std::ostream &operator<<(std::ostream &output, const Token &tokenToPrint);
};
#endif