jdk.nashorn.internal.runtime.regexp.joni.exception.JOniException Java Examples

The following examples show how to use jdk.nashorn.internal.runtime.regexp.joni.exception.JOniException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JoniRegExp.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            final char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    } catch (StackOverflowError e3) {
        throw new RuntimeException(e3);
    }
}
 
Example #2
Source File: JoniRegExp.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            final char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    }
}
 
Example #3
Source File: JoniRegExp.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            final char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    } catch (StackOverflowError e3) {
        throw new RuntimeException(e3);
    }
}
 
Example #4
Source File: JoniRegExp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            final char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    }
}
 
Example #5
Source File: JoniRegExp.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            final char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    }
}
 
Example #6
Source File: JoniRegExp.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            final char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    }
}
 
Example #7
Source File: JoniRegExp.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    }
}
 
Example #8
Source File: JoniRegExp.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    }
}
 
Example #9
Source File: JoniRegExp.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            final char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    } catch (StackOverflowError e3) {
        throw new RuntimeException(e3);
    }
}
 
Example #10
Source File: JoniRegExp.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Regular expression from the given {@code pattern} and {@code flags} strings.
 *
 * @param pattern RegExp pattern string
 * @param flags RegExp flag string
 * @throws ParserException if flags is invalid or pattern string has syntax error.
 */
public JoniRegExp(final String pattern, final String flags) throws ParserException {
    super(pattern, flags);

    int option = Option.SINGLELINE;

    if (this.isIgnoreCase()) {
        option |= Option.IGNORECASE;
    }
    if (this.isMultiline()) {
        option &= ~Option.SINGLELINE;
        option |= Option.NEGATE_SINGLELINE;
    }

    try {
        RegExpScanner parsed;

        try {
            parsed = RegExpScanner.scan(pattern);
        } catch (final PatternSyntaxException e) {
            // refine the exception with a better syntax error, if this
            // passes, just rethrow what we have
            Pattern.compile(pattern, 0);
            throw e;
        }

        if (parsed != null) {
            char[] javaPattern = parsed.getJavaPattern().toCharArray();
            this.regex = new Regex(javaPattern, 0, javaPattern.length, option, Syntax.JAVASCRIPT);
            this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead();
        }
    } catch (final PatternSyntaxException | JOniException e2) {
        throwParserException("syntax", e2.getMessage());
    }
}