woops
This commit is contained in:
@@ -406,35 +406,14 @@ public class Main {
|
||||
String s3 = "(a|b)+a";
|
||||
|
||||
String s4 = "a+((ab)*b|ab|(b)*bb)+(abba|baab)+";
|
||||
String s5 = "((ab)*b(a|b)|ab|(b)*bb)+";
|
||||
String s5 = "a(ab)*b(a|b)|ab|(b)*bb";
|
||||
String s6 = "(fuck)+";
|
||||
String s7 = "(a|b)";
|
||||
|
||||
RegExp reg = new RegExp();
|
||||
// System.out.println(reg.toRegExp("a*|b+").getTaal(5));
|
||||
|
||||
// RegExp r1 = new RegExp("a");
|
||||
// RegExp r2 = new RegExp("b");
|
||||
//
|
||||
// RegExp r3 = r1.punt(r2);
|
||||
//
|
||||
// RegExp r4 = new RegExp();
|
||||
//
|
||||
// RegExp r5 = r3.punt(r4);
|
||||
//
|
||||
// traverseRegExp(r5);
|
||||
// System.out.println(aantalOperators(r5, 1));
|
||||
// System.out.println(r5.getTaal(5));
|
||||
|
||||
// RegExp all = bSter.punt(aPlus);
|
||||
// RegExp all = r1.punt(r2.ster()).punt(r3.plus());
|
||||
//
|
||||
// System.out.println(all.getTaal(5));
|
||||
// reg.parseString(s);
|
||||
// reg.parseString(s2);
|
||||
// System.out.println(reg.parseString(s4).getTaal(3));
|
||||
// System.out.println(aantalOperators(reg.parseString(s2),1));
|
||||
// System.out.println(aantalOperators(reg.parseString(s4), 1));
|
||||
System.out.println(aantalOperators(reg.parseString(s5), 1));
|
||||
// System.out.println(reg.parseString(s3).getTaal(100)); // werkte!
|
||||
// System.out.println(reg.naarRegExp(s3).getTaal(10));
|
||||
System.out.println(reg.naarRegExp(s7).getTaal(10));
|
||||
|
||||
new Frame();
|
||||
}
|
||||
|
||||
@@ -84,7 +84,14 @@ public class RegExp extends Importable{
|
||||
}
|
||||
|
||||
public RegExp naarRegExp(String s) {
|
||||
// String s is zonder spaces
|
||||
|
||||
StringBuilder noSpacesString = new StringBuilder();
|
||||
|
||||
for (char c : s.toCharArray()) {
|
||||
if (c != ' ') {
|
||||
noSpacesString.append(c);
|
||||
}
|
||||
}
|
||||
// RegExp retval = new RegExp();
|
||||
// Als eerste moet de string in groupen gedeeld worden op basis van haakjes.
|
||||
// bijv. "a+((ab)*b|ab|(b)*bb)+(abba|baab)+" naar ["a+", [ [["ab"], "*b"], ["ab"], [["b"], "*bb"], "+" ], [ ["abba", "baab"], "+"] ]
|
||||
@@ -92,7 +99,7 @@ public class RegExp extends Importable{
|
||||
// a.plus().punt( (ab.ster().punt(b).of(ab).of(b.ster().punt(bb)).plus()) ).punt( abba.punt().baab.plus() )
|
||||
// Niet gelukt.
|
||||
// System.out.println("We lopen door " + s);
|
||||
RegExp r = loopRecursiefDoorString(s, new RegExp());
|
||||
RegExp r = loopRecursiefDoorString(noSpacesString.toString(), new RegExp());
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -118,12 +125,12 @@ public class RegExp extends Importable{
|
||||
|
||||
// System.out.println("OfStrings: " + strings);
|
||||
|
||||
ArrayList<RegExp> toDot = new ArrayList<>();
|
||||
RegExp retval = new RegExp();
|
||||
toDot.add(initieel);
|
||||
// toDot.add(initieel);
|
||||
|
||||
for (String s : strings) {
|
||||
RegExp total = new RegExp();
|
||||
ArrayList<RegExp> toDot = new ArrayList<>();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char current = s.charAt(i);
|
||||
RegExp prev;
|
||||
|
||||
Reference in New Issue
Block a user