-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToken.java
More file actions
57 lines (53 loc) · 2.04 KB
/
Token.java
File metadata and controls
57 lines (53 loc) · 2.04 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*******************************************************************
* Token Class *
* *
* PROGRAMMER: Emily Culp*
* COURSE: CS340 *
* DATE: 12/10/2024 *
* REQUIREMENT: Final - Compiler *
* *
* DESCRIPTION: *
* The Token class represents a token used in the interpreter. *
* Each token has an associated token ID and a name. This class provides *
* methods to retrieve the token's ID and name. Tokens are fundamental in *
* parsing and interpreting the programming language's syntax and operators. *
* *
* COPYRIGHT: This code is copyright (C) 2024 Emily Culp*
* and Professor Zeller. *
* *
* CREDITS: This code was written with the help of ChatGPT. *
* *
*******************************************************************/
public class Token {
private int tokenID;
private String name;
/**********************************************************
* METHOD: Token(int tokenID, String name) *
* DESCRIPTION: Constructor that initializes a Token object with the given token ID and name. *
* PARAMETERS: int tokenID - the ID associated with the token. *
* String name - the name of the token. *
* RETURN VALUE: none *
**********************************************************/
public Token(int tokenID, String name) {
this.tokenID = tokenID;
this.name = name;
}
/**********************************************************
* METHOD: getTokenID() *
* DESCRIPTION: Retrieves the token ID of the token. *
* PARAMETERS: none *
* RETURN VALUE: int - the token ID associated with the token. *
**********************************************************/
public int getTokenID() {
return tokenID;
}
/**********************************************************
* METHOD: getName() *
* DESCRIPTION: Retrieves the name of the token. *
* PARAMETERS: none *
* RETURN VALUE: String - the name of the token. *
**********************************************************/
public String getName() {
return name;
}
}