forked from runtimeverification/k
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTerminal.java
More file actions
76 lines (59 loc) · 1.72 KB
/
Terminal.java
File metadata and controls
76 lines (59 loc) · 1.72 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2012-2019 K Team. All Rights Reserved.
package org.kframework.kil;
import org.kframework.utils.StringUtil;
/** A terminal in a {@link Production}. */
public class Terminal extends ProductionItem {
private String terminal;
private boolean caseInsensitive = false;
public Terminal(String terminal, boolean caseInsensitive) {
super();
this.terminal = terminal;
this.caseInsensitive = caseInsensitive;
}
public Terminal(String terminal) {
super();
this.terminal = terminal;
}
public Terminal(Terminal terminal) {
super(terminal);
this.terminal = terminal.terminal;
this.caseInsensitive = terminal.caseInsensitive;
}
public void setTerminal(String terminal) {
this.terminal = terminal;
}
public String getTerminal() {
return terminal;
}
@Override
public String toString() {
return StringUtil.enquoteCString(terminal, caseInsensitive ? '\'' : '"');
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj == this)
return true;
if (!(obj instanceof Terminal))
return false;
Terminal trm = (Terminal) obj;
if (!trm.terminal.equals(this.terminal))
return false;
return true;
}
@Override
public int hashCode() {
return this.terminal.hashCode();
}
@Override
public Terminal shallowCopy() {
return new Terminal(this);
}
public boolean isCaseInsensitive() {
return caseInsensitive;
}
public void setCaseInsensitive(boolean caseInsensitive) {
this.caseInsensitive = caseInsensitive;
}
}