static private RegExp makeString(RegExp exp1, RegExp exp2) { StringBuilder b = new StringBuilder(); if (exp1.kind == Kind.REGEXP_STRING) b.append(exp1.s); else b.appendCodePoint(exp1.c); if (exp2.kind == Kind.REGEXP_STRING) b.append(exp2.s); else b.appendCodePoint(exp2.c); return makeString(b.toString()); }
static RegExp makeConcatenation(RegExp exp1, RegExp exp2) { if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) return makeString( exp1, exp2); RegExp r = new RegExp(); r.kind = Kind.REGEXP_CONCATENATION; if (exp1.kind == Kind.REGEXP_CONCATENATION && (exp1.exp2.kind == Kind.REGEXP_CHAR || exp1.exp2.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) { r.exp1 = exp1.exp1; r.exp2 = makeString(exp1.exp2, exp2); } else if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && exp2.kind == Kind.REGEXP_CONCATENATION && (exp2.exp1.kind == Kind.REGEXP_CHAR || exp2.exp1.kind == Kind.REGEXP_STRING)) { r.exp1 = makeString(exp1, exp2.exp1); r.exp2 = exp2.exp2; } else { r.exp1 = exp1; r.exp2 = exp2; } return r; }
/** * Constructs new <code>RegExp</code> from a string. * * @param s regexp string * @param syntax_flags boolean 'or' of optional syntax constructs to be * enabled * @exception IllegalArgumentException if an error occured while parsing the * regular expression */ public RegExp(String s, int syntax_flags) throws IllegalArgumentException { originalString = s; flags = syntax_flags; RegExp e; if (s.length() == 0) e = makeString(""); else { e = parseUnionExp(); if (pos < originalString.length()) throw new IllegalArgumentException( "end-of-string expected at position " + pos); } kind = e.kind; exp1 = e.exp1; exp2 = e.exp2; this.s = e.s; c = e.c; min = e.min; max = e.max; digits = e.digits; from = e.from; to = e.to; }
if (!match('"')) throw new IllegalArgumentException( "expected '\"' at position " + pos); return makeString(originalString.substring(start, pos - 1)); } else if (match('(')) { if (match(')')) return makeString(""); RegExp e = parseUnionExp(); if (!match(')')) throw new IllegalArgumentException(
static private RegExp makeString(RegExp exp1, RegExp exp2) { StringBuilder b = new StringBuilder(); if (exp1.kind == Kind.REGEXP_STRING) b.append(exp1.s); else b.appendCodePoint(exp1.c); if (exp2.kind == Kind.REGEXP_STRING) b.append(exp2.s); else b.appendCodePoint(exp2.c); return makeString(b.toString()); }
static private RegExp makeString(RegExp exp1, RegExp exp2) { StringBuilder b = new StringBuilder(); if (exp1.kind == Kind.REGEXP_STRING) b.append(exp1.s); else b.appendCodePoint(exp1.c); if (exp2.kind == Kind.REGEXP_STRING) b.append(exp2.s); else b.appendCodePoint(exp2.c); return makeString(b.toString()); }
static RegExp makeConcatenation(RegExp exp1, RegExp exp2) { if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) return makeString( exp1, exp2); RegExp r = new RegExp(); r.kind = Kind.REGEXP_CONCATENATION; if (exp1.kind == Kind.REGEXP_CONCATENATION && (exp1.exp2.kind == Kind.REGEXP_CHAR || exp1.exp2.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) { r.exp1 = exp1.exp1; r.exp2 = makeString(exp1.exp2, exp2); } else if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && exp2.kind == Kind.REGEXP_CONCATENATION && (exp2.exp1.kind == Kind.REGEXP_CHAR || exp2.exp1.kind == Kind.REGEXP_STRING)) { r.exp1 = makeString(exp1, exp2.exp1); r.exp2 = exp2.exp2; } else { r.exp1 = exp1; r.exp2 = exp2; } return r; }
static private RegExp makeString(RegExp exp1, RegExp exp2) { StringBuilder b = new StringBuilder(); if (exp1.kind == Kind.REGEXP_STRING) b.append(exp1.s); else b.appendCodePoint(exp1.c); if (exp2.kind == Kind.REGEXP_STRING) b.append(exp2.s); else b.appendCodePoint(exp2.c); return makeString(b.toString()); }
static RegExp makeConcatenation(RegExp exp1, RegExp exp2) { if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) return makeString( exp1, exp2); RegExp r = new RegExp(); r.kind = Kind.REGEXP_CONCATENATION; if (exp1.kind == Kind.REGEXP_CONCATENATION && (exp1.exp2.kind == Kind.REGEXP_CHAR || exp1.exp2.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) { r.exp1 = exp1.exp1; r.exp2 = makeString(exp1.exp2, exp2); } else if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && exp2.kind == Kind.REGEXP_CONCATENATION && (exp2.exp1.kind == Kind.REGEXP_CHAR || exp2.exp1.kind == Kind.REGEXP_STRING)) { r.exp1 = makeString(exp1, exp2.exp1); r.exp2 = exp2.exp2; } else { r.exp1 = exp1; r.exp2 = exp2; } return r; }
static RegExp makeConcatenation(RegExp exp1, RegExp exp2) { if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) return makeString( exp1, exp2); RegExp r = new RegExp(); r.kind = Kind.REGEXP_CONCATENATION; if (exp1.kind == Kind.REGEXP_CONCATENATION && (exp1.exp2.kind == Kind.REGEXP_CHAR || exp1.exp2.kind == Kind.REGEXP_STRING) && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) { r.exp1 = exp1.exp1; r.exp2 = makeString(exp1.exp2, exp2); } else if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING) && exp2.kind == Kind.REGEXP_CONCATENATION && (exp2.exp1.kind == Kind.REGEXP_CHAR || exp2.exp1.kind == Kind.REGEXP_STRING)) { r.exp1 = makeString(exp1, exp2.exp1); r.exp2 = exp2.exp2; } else { r.exp1 = exp1; r.exp2 = exp2; } return r; }
/** * Constructs new <code>RegExp</code> from a string. * * @param s regexp string * @param syntax_flags boolean 'or' of optional syntax constructs to be * enabled * @exception IllegalArgumentException if an error occured while parsing the * regular expression */ public RegExp(String s, int syntax_flags) throws IllegalArgumentException { originalString = s; flags = syntax_flags; RegExp e; if (s.length() == 0) e = makeString(""); else { e = parseUnionExp(); if (pos < originalString.length()) throw new IllegalArgumentException( "end-of-string expected at position " + pos); } kind = e.kind; exp1 = e.exp1; exp2 = e.exp2; this.s = e.s; c = e.c; min = e.min; max = e.max; digits = e.digits; from = e.from; to = e.to; }
/** * Constructs new <code>RegExp</code> from a string. * * @param s regexp string * @param syntax_flags boolean 'or' of optional syntax constructs to be * enabled * @exception IllegalArgumentException if an error occured while parsing the * regular expression */ public RegExp(String s, int syntax_flags) throws IllegalArgumentException { originalString = s; flags = syntax_flags; RegExp e; if (s.length() == 0) e = makeString(""); else { e = parseUnionExp(); if (pos < originalString.length()) throw new IllegalArgumentException( "end-of-string expected at position " + pos); } kind = e.kind; exp1 = e.exp1; exp2 = e.exp2; this.s = e.s; c = e.c; min = e.min; max = e.max; digits = e.digits; from = e.from; to = e.to; }
/** * Constructs new <code>RegExp</code> from a string. * * @param s regexp string * @param syntax_flags boolean 'or' of optional syntax constructs to be * enabled * @exception IllegalArgumentException if an error occured while parsing the * regular expression */ public RegExp(String s, int syntax_flags) throws IllegalArgumentException { originalString = s; flags = syntax_flags; RegExp e; if (s.length() == 0) e = makeString(""); else { e = parseUnionExp(); if (pos < originalString.length()) throw new IllegalArgumentException( "end-of-string expected at position " + pos); } kind = e.kind; exp1 = e.exp1; exp2 = e.exp2; this.s = e.s; c = e.c; min = e.min; max = e.max; digits = e.digits; from = e.from; to = e.to; }
if (!match('"')) throw new IllegalArgumentException( "expected '\"' at position " + pos); return makeString(originalString.substring(start, pos - 1)); } else if (match('(')) { if (match(')')) return makeString(""); RegExp e = parseUnionExp(); if (!match(')')) throw new IllegalArgumentException(
if (!match('"')) throw new IllegalArgumentException( "expected '\"' at position " + pos); return makeString(originalString.substring(start, pos - 1)); } else if (match('(')) { if (match(')')) return makeString(""); RegExp e = parseUnionExp(); if (!match(')')) throw new IllegalArgumentException(
if (!match('"')) throw new IllegalArgumentException( "expected '\"' at position " + pos); return makeString(originalString.substring(start, pos - 1)); } else if (match('(')) { if (match(')')) return makeString(""); RegExp e = parseUnionExp(); if (!match(')')) throw new IllegalArgumentException(