in jflex/src/main/java/jflex/core/RegExp.java [431:502]
public RegExp expandPreClasses(Map<Integer, IntCharSet> cache, CharClasses cl, boolean caseless) {
RegExp1 unary;
RegExp2 binary;
RegExp content;
switch (type) {
case sym.BAR:
case sym.CONCAT:
binary = (RegExp2) this;
return new RegExp2(
type,
binary.r1.expandPreClasses(cache, cl, caseless),
binary.r2.expandPreClasses(cache, cl, caseless));
case sym.STAR:
case sym.PLUS:
case sym.QUESTION:
case sym.BANG:
case sym.TILDE:
unary = (RegExp1) this;
content = (RegExp) unary.content;
return new RegExp1(type, content.expandPreClasses(cache, cl, caseless));
case sym.CCLASS:
case sym.CCLASSNOT:
{
unary = (RegExp1) this;
List<RegExp> contents = (List<RegExp>) unary.content;
List<RegExp> newContents = new ArrayList<RegExp>(contents.size());
for (RegExp r : contents) {
RegExp n = r.expandPreClasses(cache, cl, caseless);
newContents.add(n);
}
return new RegExp1(type, newContents);
}
case sym.CCLASSOP:
unary = (RegExp1) this;
binary = (RegExp2) unary.content;
RegExp l = binary.r1.expandPreClasses(cache, cl, caseless);
RegExp r = binary.r2.expandPreClasses(cache, cl, caseless);
return new RegExp1(type, new RegExp2(binary.type, l, r));
case sym.PRECLASS:
{
unary = (RegExp1) this;
IntCharSet set = getPreClass(cache, cl, (Integer) unary.content);
return new RegExp1(sym.PRIMCLASS, set);
}
case sym.UNIPROPCCLASS:
{
unary = (RegExp1) this;
IntCharSet set = cl.getUnicodeProperties().getIntCharSet((String) unary.content);
if (caseless) {
set = set.getCaseless(cl.getUnicodeProperties());
}
return new RegExp1(sym.PRIMCLASS, set);
}
case sym.STRING:
case sym.STRING_I:
case sym.CHAR:
case sym.CHAR_I:
case sym.PRIMCLASS:
unary = (RegExp1) this;
return new RegExp1(type, unary.content);
default:
throw new RegExpException(this);
}
}