Added RegExp

This commit is contained in:
2017-05-02 14:20:19 +02:00
parent f6c4bb5e36
commit 4c0a594ef8
4 changed files with 263 additions and 1 deletions
+74
View File
@@ -0,0 +1,74 @@
package com.imegumii;
import java.util.Comparator;
/**
* Created by kenny on 2-5-2017.
*/
public class RegExp {
public enum Operator { PLUS, STER, OF, PUNT, EEN}
Operator operator;
String characters;
RegExp links;
RegExp rechts;
static final Comparator<String> vergelijkDmvLengte = (s1, s2) -> {
if (s1.length() == s2.length())
{return s1.compareTo(s2);}
else
{return s1.length() - s2.length();}
};
public RegExp()
{
operator = Operator.EEN;
characters = "";
links = null;
rechts = null;
}
public RegExp(String chars){
operator = Operator.EEN;
characters = chars;
links = null;
rechts = null;
}
public RegExp plus()
{
RegExp res = new RegExp();
res.operator = Operator.PLUS;
res.links = this;
return res;
}
public RegExp ster()
{
RegExp res = new RegExp();
res.operator = Operator.STER;
res.links = this;
return res;
}
public RegExp of(RegExp other)
{
RegExp res = new RegExp();
res.operator = Operator.OF;
res.links = this;
res.rechts = other;
return res;
}
public RegExp punt(RegExp other)
{
RegExp res = new RegExp();
res.operator = Operator.PUNT;
res.links = this;
res.rechts = other;
return res;
}
}