-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.java
94 lines (77 loc) · 1.16 KB
/
Node.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Calculator
*
* version 1
*
* August 3, 2019
*
* Copyright © 2019 Sabrina Kim, Martial Pastor, Keven Presseau-St-Laurent, Marco Tropiano, Diana Zitting-Rioux. All rights reserved.
*/
import java.util.ArrayList;
/**
* Node class for the parser
*
* @version 1
* @author Martial Pastor
*
*/
public class Node {
String lexeme;
String type;
Node parent;
ArrayList<Node> children = new ArrayList<Node>();
int id;
Node(String l, String t, int i){
lexeme = l;
type = t;
id = i;
}
/**
* Get ID
* @return id
*/
public int getID() {
return id;
}
/**
* Get lexeme
* @return lexeme
*/
public String getLexeme() {
return lexeme;
}
/**
* get Type
* @return type
*/
public String getType() {
return type;
}
/**
* Set parents
* @param p
*/
public void setParent(Node p){
parent = p ;
}
/**
* Add children
* @param child
*/
public void addChildren(Node child) {
children.add(child);
}
/**
* To string
*/
public String toString() {
return type + "[" + lexeme + "]";
}
/**
* Get children
* @return
*/
public ArrayList<Node> getChildren(){
return children;
}
}