public Regex(final char[] chars, final int p, final int end, final int optionp, final int caseFoldFlag, final Syntax syntax, final WarnCallback warnings) { int option = optionp; if ((option & (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) == (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) { throw new ValueException(ErrorMessages.ERR_INVALID_COMBINATION_OF_OPTIONS); } if ((option & Option.NEGATE_SINGLELINE) != 0) { option |= syntax.options; option &= ~Option.SINGLELINE; } else { option |= syntax.options; } this.options = option; this.caseFoldFlag = caseFoldFlag; this.warnings = warnings; this.analyser = new Analyser(new ScanEnvironment(this, syntax), chars, p, end); this.analyser.compile(); this.warnings = null; }
private void fetchTokenInCCFor_u() { if (!left()) { return; } final int last = p; if (syntax.op2EscUHex4()) { int num = scanUnsignedHexadecimalNumber(4); if (num < 0) { throw new ValueException(ERR_TOO_BIG_NUMBER); } if (p == last) { /* can't read nothing. */ num = 0; /* but, it's not error */ } token.type = TokenType.CODE_POINT; token.setCode(num); } }
private void fetchTokenFor_uHex() { if (!left()) { return; } final int last = p; if (syntax.op2EscUHex4()) { int num = scanUnsignedHexadecimalNumber(4); if (num < 0) { throw new ValueException(ERR_TOO_BIG_NUMBER); } if (p == last) { /* can't read nothing. */ num = 0; /* but, it's not error */ } token.type = TokenType.CODE_POINT; token.setCode(num); } }
private void fetchTokenFor_digit() { unfetch(); final int last = p; final int num = scanUnsignedNumber(); if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref } else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */ if (syntax.strictCheckBackref()) { if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) { throw new ValueException(ERR_INVALID_BACKREF); } } token.type = TokenType.BACKREF; token.setBackrefRef(num); return; } if (c == '8' || c == '9') { /* normal char */ // skip_backref: p = last; inc(); return; } p = last; fetchTokenFor_zero(); /* fall through */ }
private void fetchTokenFor_zero() { if (syntax.opEscOctal3()) { final int last = p; int num = scanUnsignedOctalNumber(c == '0' ? 2 : 3); if (num < 0) { throw new ValueException(ERR_TOO_BIG_NUMBER); } if (p == last) { /* can't read nothing. */ num = 0; /* but, it's not error */ } token.type = TokenType.RAW_BYTE; token.setC(num); } else if (c != '0') { inc(); } }
public Regex(final char[] chars, final int p, final int end, final int optionp, final int caseFoldFlag, final Syntax syntax, final WarnCallback warnings) { int option = optionp; if ((option & (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) == (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) { throw new ValueException(ErrorMessages.ERR_INVALID_COMBINATION_OF_OPTIONS); } if ((option & Option.NEGATE_SINGLELINE) != 0) { option |= syntax.options; option &= ~Option.SINGLELINE; } else { option |= syntax.options; } this.options = option; this.caseFoldFlag = caseFoldFlag; this.warnings = warnings; new Analyser(new ScanEnvironment(this, syntax), chars, p, end).compile(); this.warnings = null; }
public Regex(char[] chars, int p, int end, int option, int caseFoldFlag, Syntax syntax, WarnCallback warnings) { if ((option & (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) == (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) { throw new ValueException(ErrorMessages.ERR_INVALID_COMBINATION_OF_OPTIONS); } if ((option & Option.NEGATE_SINGLELINE) != 0) { option |= syntax.options; option &= ~Option.SINGLELINE; } else { option |= syntax.options; } this.options = option; this.caseFoldFlag = caseFoldFlag; this.warnings = warnings; this.analyser = new Analyser(new ScanEnvironment(this, syntax), chars, p, end); this.analyser.compile(); this.warnings = null; }
private void fetchTokenInCCFor_u() { if (!left()) return; int last = p; if (syntax.op2EscUHex4()) { int num = scanUnsignedHexadecimalNumber(4); if (num < 0) { throw new ValueException(ERR_TOO_BIG_NUMBER); } if (p == last) { /* can't read nothing. */ num = 0; /* but, it's not error */ } token.type = TokenType.CODE_POINT; token.setCode(num); } }
private void fetchTokenFor_uHex() { if (!left()) return; int last = p; if (syntax.op2EscUHex4()) { int num = scanUnsignedHexadecimalNumber(4); if (num < 0) { throw new ValueException(ERR_TOO_BIG_NUMBER); } if (p == last) { /* can't read nothing. */ num = 0; /* but, it's not error */ } token.type = TokenType.CODE_POINT; token.setCode(num); } }
private void fetchTokenFor_digit() { unfetch(); int last = p; int num = scanUnsignedNumber(); if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref } else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */ if (syntax.strictCheckBackref()) { if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) { throw new ValueException(ERR_INVALID_BACKREF); } } token.type = TokenType.BACKREF; token.setBackrefRef(num); return; } if (c == '8' || c == '9') { /* normal char */ // skip_backref: p = last; inc(); return; } p = last; fetchTokenFor_zero(); /* fall through */ }
private void fetchTokenFor_zero() { if (syntax.opEscOctal3()) { int last = p; int num = scanUnsignedOctalNumber(c == '0' ? 2 : 3); if (num < 0) { throw new ValueException(ERR_TOO_BIG_NUMBER); } if (p == last) { /* can't read nothing. */ num = 0; /* but, it's not error */ } token.type = TokenType.RAW_BYTE; token.setC(num); } else if (c != '0') { inc(); } }