Sei sulla pagina 1di 2

ntifiers[j])) {

if (identifiersArray.isEmpty()) {
identifiersArray.add(identifiers[j]);
} else {
identifiersArray.add(",");
identifiersArray.add(identifiers[j]);
}

}
}

String[] others = {"\\;", "\\,", "\\(", "\\)", "\\{", "\\}"};


for (int j = 0; j < others.length; j++) {
p = Pattern.compile(others[j]);
m = p.matcher(text);

if (m.find()) {
if (!othersArray.contains(m.group())) {
if (othersArray.isEmpty()) {
othersArray.add(m.group());
} else {
othersArray.add(" ");
othersArray.add(m.group());
}
}
}
}

p = Pattern.compile("\\d*\\.?\\d+");
m = p.matcher(text);
if (m.find()) {
if (!numericalArray.contains(m.group())) {
if (numericalArray.isEmpty()) {
numericalArray.add(m.group());
} else {
numericalArray.add(",");
numericalArray.add(m.group());
}
}
}
}

sc.close();

System.out.print("Keywords: ");
for (String x : keywordArray) {
System.out.print(x);
}
System.out.println("");
System.out.print("Identifiers: ");
for (String x : identifiersArray) {
System.out.print(x);
}

System.out.println("");
System.out.print("Logical Operators: ");
for (String x : logOpArray) {
System.out.print(x);
}
System.out.println("");
System.out.print("Mathematical Operators: ");
for (String x : matOpArray) {
System.out.print(x);
}
System.out.println("");
System.out.print("Numerical Values: ");
for (String x : numericalArray) {
System.out.print(x);
}
System.out.println("");
System.out.print("Others: ");
for (String x : othersArray) {
System.out.print(x);
}
System.out.println("");

Potrebbero piacerti anche