-
Notifications
You must be signed in to change notification settings - Fork 1
/
Validity.java
142 lines (76 loc) · 2.65 KB
/
Validity.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package Discrete;
import java.util.ArrayList;
public class Validity {
ArrayList<String> list;
ArrayList<String> user_check;
ArrayList<String> variables;
ArrayList<String> operators;
public Validity() {
list = new ArrayList<String>();
user_check = new ArrayList<String>();
variables = new ArrayList<String>();
operators = new ArrayList<String>();
}
public ArrayList<String> getVariables() {
return variables;
}
public void setVariables(ArrayList<String> variables) {
this.variables = variables;
}
public ArrayList<String> getList() {
return list;
}
public void setList(ArrayList<String> list) {
this.list = list;
}
public ArrayList<String> getUser_check() {
return user_check;
}
public void setUser_check(ArrayList<String> user_check) {
this.user_check = user_check;
}
public void addSyntax(String e) {
this.getList().add(e);
}
private void breakSyntax(String str) {
for(int i = 0 ; i < str.length() ; i++) {
this.getUser_check().add(str.substring(i, i+1));
}
//System.out.println(this.getUser_check());
}
public void addUserSyntax(String str) {
this.breakSyntax(str);
}
public void chunks() {
String store = "";
boolean flag = false;
for(int i = 0 ; i < this.getUser_check().size() ; i++) {
if(Character.isLetterOrDigit(this.getUser_check().get(i).charAt(0)) ) {
store = store + this.getUser_check().get(i).charAt(0);
flag = true;
}
if(flag == true && !(Character.isLetterOrDigit(this.getUser_check().get(i).charAt(0)) )) {
this.getVariables().add(store);
flag = false;
store = "";
}
if(this.getUser_check().get(i).charAt(0) != '(' &&
this.getUser_check().get(i).charAt(0) != ')' &&
!(Character.isLetterOrDigit(this.getUser_check().get(i).charAt(0)) ))
{
if(this.getUser_check().get(i).charAt(0) == '/' && this.getUser_check().get(i+1).charAt(0) == '\\') {
this.operators.add("&");
}
else if(this.getUser_check().get(i).charAt(0) == '\\' && this.getUser_check().get(i+1).charAt(0) == '/') {
this.operators.add("|");
}
else if(this.getUser_check().get(i).charAt(0) == '-' && this.getUser_check().get(i+1).charAt(0) == '>') {
this.operators.add("->");
}
else if(this.getUser_check().get(i).charAt(0) == '~') {
this.operators.add("~");
}
}
}
}
}