├── CHANGELOG.md ├── PerformanceTestResults.html ├── README.md ├── docs ├── .project ├── apidocs │ ├── allclasses-index.html │ ├── allpackages-index.html │ ├── constant-values.html │ ├── de │ │ └── unkrig │ │ │ ├── lfr │ │ │ └── core │ │ │ │ ├── CharacterClass.html │ │ │ │ ├── Grapheme.html │ │ │ │ ├── IntPredicate.html │ │ │ │ ├── Matcher.CompiledReplacement.html │ │ │ │ ├── Matcher.html │ │ │ │ ├── Pattern.html │ │ │ │ ├── PatternFactory.html │ │ │ │ ├── ReverseCharSequence.html │ │ │ │ ├── Sequences.LiteralString.html │ │ │ │ ├── Sequences.html │ │ │ │ ├── package-summary.html │ │ │ │ └── package-tree.html │ │ │ └── ref4j │ │ │ ├── Matcher.html │ │ │ ├── Pattern.html │ │ │ ├── PatternFactory.html │ │ │ ├── package-summary.html │ │ │ └── package-tree.html │ ├── element-list │ ├── help-doc.html │ ├── index-all.html │ ├── index.html │ ├── jquery-ui.overrides.css │ ├── legal │ │ ├── ADDITIONAL_LICENSE_INFO │ │ ├── ASSEMBLY_EXCEPTION │ │ ├── LICENSE │ │ ├── jquery.md │ │ └── jqueryUI.md │ ├── member-search-index.js │ ├── module-search-index.js │ ├── overview-summary.html │ ├── overview-tree.html │ ├── package-search-index.js │ ├── resources │ │ ├── glass.png │ │ └── x.png │ ├── script-dir │ │ ├── images │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ ├── ui-bg_glass_65_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ ├── ui-icons_454545_256x240.png │ │ │ ├── ui-icons_888888_256x240.png │ │ │ └── ui-icons_cd0a0a_256x240.png │ │ ├── jquery-3.5.1.min.js │ │ ├── jquery-ui.min.css │ │ ├── jquery-ui.min.js │ │ └── jquery-ui.structure.min.css │ ├── script.js │ ├── search.js │ ├── serialized-form.html │ ├── stylesheet.css │ ├── tag-search-index.js │ └── type-search-index.js └── generate_javadoc.sh ├── lfr-core ├── .checkstyle ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.jdt.ui.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.jboss.ide.eclipse.as.core.prefs ├── launch │ ├── lfr-core jre11.launch │ ├── lfr-core jre17.launch │ └── lfr-core jre8.launch ├── pom.xml └── src │ ├── main │ ├── java │ │ └── de │ │ │ └── unkrig │ │ │ └── lfr │ │ │ └── core │ │ │ ├── CharacterClass.java │ │ │ ├── CharacterClasses.java │ │ │ ├── CompositeSequence.java │ │ │ ├── Grapheme.java │ │ │ ├── IntPredicate.java │ │ │ ├── Matcher.java │ │ │ ├── MatcherImpl.java │ │ │ ├── MultivalentCharClass.java │ │ │ ├── MultivalentCharacterClass.java │ │ │ ├── MultivalentSequence.java │ │ │ ├── Pattern.java │ │ │ ├── PatternFactory.java │ │ │ ├── ReverseCharSequence.java │ │ │ ├── Sequence.java │ │ │ ├── Sequences.java │ │ │ └── package-info.java │ ├── javadoc │ │ ├── overview.html │ │ ├── package-lists │ │ │ └── de.unkrig.commons │ │ │ │ └── commons-text │ │ │ │ └── package-list │ │ └── stylesheet.css │ └── resources │ │ └── META-INF │ │ └── services │ │ └── de.unkrig.ref4j.PatternFactory │ └── test │ └── java │ └── test │ ├── FunctionalityEquivalencePatternFactory.java │ ├── Misc.java │ ├── OracleEssentials.java │ ├── OracleEssentialsTest.java │ ├── ParameterizedWithPatternFactory.java │ ├── PatternTest.java │ ├── PerformanceMeasurement.java │ ├── PerformanceMeasurementPatternFactory.java │ ├── PerformanceTests.java │ ├── Sampler.java │ └── package-info.java ├── lfr-parent ├── .keep ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.m2e.core.prefs └── pom.xml ├── openjdk15_regex_tests ├── .classpath ├── .keep ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── launch │ ├── openjdk15_regex_tests (JRE 11).launch │ ├── openjdk15_regex_tests (JRE 17).launch │ └── openjdk15_regex_tests (JRE 8).launch ├── pom.xml └── src │ ├── main │ ├── java │ │ └── .keep │ └── resources │ │ └── .keep │ └── test │ ├── java │ ├── GraphemeTest.java.txt │ ├── NegativeArraySize.java.txt │ ├── POSIX_ASCII.java │ ├── POSIX_Unicode.java │ ├── PatternStreamTest.java.txt │ ├── RegExTest.java │ └── RegExTest.java.orig │ └── resources │ ├── BMPTestCases.txt │ ├── GraphemeTestCases.txt │ ├── SupplementaryTestCases.txt │ └── TestCases.txt ├── openjdk8_regex_tests ├── .checkstyle ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── README.md ├── launch │ ├── openjdk8_regex_tests (JRE 11).launch │ ├── openjdk8_regex_tests (JRE 17).launch │ └── openjdk8_regex_tests (JRE 8).launch ├── pom.xml └── src │ ├── main │ ├── java │ │ └── .empty │ └── resources │ │ └── .empty │ └── test │ ├── java │ ├── POSIX_ASCII.java │ ├── POSIX_Unicode.java │ └── RegExTest.java │ └── resources │ ├── BMPTestCases.txt │ ├── SupplementaryTestCases.txt │ └── TestCases.txt └── ref4j ├── .checkstyle ├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── foo.txt ├── pom.xml └── src ├── main ├── java │ └── de │ │ └── unkrig │ │ └── ref4j │ │ ├── Matcher.java │ │ ├── Pattern.java │ │ ├── PatternFactory.java │ │ ├── jur │ │ ├── PatternFactory.java │ │ └── package-info.java │ │ └── package-info.java └── resources │ └── META-INF │ └── services │ └── de.unkrig.ref4j.PatternFactory └── test └── java └── ref4j ├── Ref4JTests.java └── package-info.java /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### Version 1.2.0: 2 | 3 | * Added missing JRE 8 methods to "Pattern" for JRE 8-17 compatibility. 4 | * Gave up on JRE 6 compatibility - minimum JRE verseion is now 8. 5 | * Fixed some scanning rules in "comment mode". 6 | * Catch infinite quantities of zero-width operand (creates an endless look otherwise). 7 | * Fixed the backtracking of "\r\n" sequences (may pose *two* (!) line breaks!). 8 | * Fixed allowed characters in capturing group names. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lightning-fast Regular Expressions for Java 2 | 3 | Lightning-fast Regular Expressions ("LFR") is a 99.9%-complete reimplementation of `java.util.regex` ("JUR") with better `match()` and `find()` performance. Yet the design is much cleaner and easier to understand and extend. 4 | 5 | LFR is (successfully) tested against the official OpenJDK 15 regex regression test suite. 6 | 7 | ## Differences between LFR and JUR 8 | 9 | ### FUNCTIONAL DIFFERENCES 10 | 11 | All features of JUR are available and functionally identical, except for the following differences: 12 | 13 | Minus: 14 | 15 | * `Pattern.CANON_EQ` (a really obscure, hopefully rarely used feature) is not implemented. You get an `IllegalArgumentException` when you invoke LFR `Pattern.compile()` with this flag. 16 | 17 | Plus: 18 | 19 | * Lookbehinds are no longer limited to fixed-length expressions. 20 | 21 | * LFR's `Matcher.replaceFirst/All()` methods can not only replace with numered group (`$1`) or named group (`${name}`), but also with a Java-like expression; e.g. 22 | 23 |    `PatternFactory.INSTANCE.compile("(?a)").matcher("abc").replaceAll("${3 + 4 + grp + m.groupCount()}")` 24 | 25 | returns 26 | 27 |    `"7a1bc"` 28 | 29 | The expression syntax is described [here](https://aunkrig.github.io/lfr/apidocs/de/unkrig/lfr/core/Matcher.html#compileReplacement-java.lang.String-). 30 | 31 | ### API DIFFERENCES 32 | 33 | The classes `Pattern` and `Matcher` were duplicated from the JUR (package `java.util.regex`) to LFR (package `de.unkrig.lfr.core`) with identical fields and methods. 34 | 35 | The JUR `MatchResult` and `PatternSyntaxException` were re-used instead of being duplicated. 36 | 37 | There are the following differences in the API: 38 | 39 | Minus: 40 | 41 | * Some JRE classes use JUR internally, and cannot be retrofitted to use LFR. However, all these methods use `Pattern.compile()`, so you don't want to use them in performance-critical applications. Examples: `String.matches(regex)`, `String.replaceFirst(regex, replacement)`, `String.replaceAll(regex, replacement)`, `String.split(regex[, limit])`, `java.util.Scanner.next(Pattern)` (Actually not a minus in the LFR API, but in the JRE APIs.) 42 | 43 | Plus: 44 | 45 | * The LFR `Pattern` class has three additional methods `matches(CharSequence subject[, regionStart[, regionEnd]])`, which are particularly fast because they do not expose the `Matcher` object and can thus save some overhead. 46 | 47 | * The LFR `Pattern` class has an additional method `sequenceToString()` which returns a human-readable form of the compiled regex. For example, `compile("A.*abcdefghijklmn", DOTALL).sequenceToString()` returns 48 | 49 |    `'A' . greedyQuantifierOnAnyCharAndLiteralString(min=0, max=infinite, ls=boyerMooreHorspool("abcdefghijklmn"))` 50 | 51 | This is useful for testing how a regex compiled, and especially which optimizations have taken place. 52 | 53 | * LFR only requires JRE 1.8+, but makes some later features available for earlier JREs: 54 | * JUR features that appeared in JRE 1.9: 55 | * Named Unicode characters, e.g. `\N{LATIN SMALL LETTER O}` (only if executed in a JRE 9+) 56 | * (Unicode extended graphemes -- are not (yet) supported.) 57 | * JUR features that appeared in JREs 10, 11, 12, 13, 14, 15, 16 and 17: 58 | * (None.) 59 | 60 | * Although LFR requires only JRE 8+, the methods that were added later (namely with Java 9: `Matcher.replaceFirst(Function)`, `Matcher.replaceAll(Function)`, `Matcher.results()`) are always available. 61 | 62 | ## Performance 63 | 64 | Minus: 65 | 66 | * Regex compilation performance was not measured and is probably quite slow (as with JUR). There is surely a lot of room for optimization in this area, if someone needs it. 67 | 68 | Plus: 69 | 70 | * Regex evaluation (`Matcher.matches()`, `find()`, `lookingAt()`, ...) is roughly [four times as fast as with JUR](https://gitcdn.link/cdn/aunkrig/lfr/master/PerformanceTestResults.html). This was measured with the LFR test case suite and [Performance comparison of regular expression engines](https://zherczeg.github.io/sljit/regex_perf.html). Other use cases (other regexes, other subjects, other API calls, ...) may yield different results. 71 | 72 | * LFR specifically improves the evaluation performance for the following special cases: 73 | 74 | * Patterns that start with literal characters (or character classes, or alternatives) (for `Matcher.find()`) 75 | 76 | * Patterns that contain a greedy or reluctant quantifier of ANY, followed by literal characters (or character classes, or alternatives); e.g. `"xxx.*ABCDEFGHIJKLMNOPxxx"` (or `"(?i)xxx.+foobar"`, or `"xxx.{4,39}?(?:alpha|beta|gamma)"`) 77 | 78 | * Patterns that contain a possessive quantifier of ANY; e.g. `"xxx.++xxx"` 79 | 80 | "ANY" means the "." pattern, and the DOTALL flag being active. ("." *without* the DOTALL flag being active means "any character except a line terminator".) 81 | 82 | ## Facade 83 | 84 | If you want to switch between JUR and LFR (and other, not yet written RE implementations) at *runtime*, you can use "`de.unkrig.ref4j`", the "regular expressions facade for Java": 85 | 86 | de.unkrig.ref4j.PatternFactory pf = PatternFactory.get(); // Gets the PF designated by the system property "de.unkrig.ref4j.PatternFactory", or the first PF on the classpath 87 | de.unkrig.ref4j.Pattern p = pf.compile(regex); 88 | ... 89 | 90 | ## Integration 91 | 92 | All versions of LFR are available on [MAVEN CENTRAL](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22de.unkrig.lfr%22); download the latest JAR file from there, or add it as a MAVEN dependency. 93 | 94 | JAVADOC can be found [here](https://aunkrig.github.io/lfr/apidocs/de/unkrig/lfr/core/package-summary.html). 95 | 96 | ## License 97 | 98 | de.unkrig.lfr - A super-fast regular expression evaluator 99 | 100 | Copyright (c) 2017, Arno Unkrig 101 | All rights reserved. 102 | 103 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 104 | 105 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and thefollowing disclaimer. 106 | 107 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 108 | 109 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 110 | 111 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 112 | -------------------------------------------------------------------------------- /docs/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | docs 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/apidocs/allpackages-index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | All Packages 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 24 |
25 | 48 |
49 |
50 |
51 |

All Packages

52 |
53 |
Package Summary
54 |
55 |
Package
56 |
Description
57 | 58 |
59 |
A super-fast drop-in replacement for java.util.regex.
60 |
61 | 62 |
 
63 |
64 |
65 |
66 |
67 | 68 | 69 | -------------------------------------------------------------------------------- /docs/apidocs/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Constant Field Values 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 24 |
25 | 48 |
49 |
50 |
51 |

Constant Field Values

52 |
53 |

Contents

54 | 57 |
58 |
59 |
60 |

de.unkrig.*

61 |
    62 |
  • 63 |
    de.unkrig.ref4j.Pattern
    64 |
    65 |
    Modifier and Type
    66 |
    Constant Field
    67 |
    Value
    68 |
    public static final int
    69 | 70 |
    128
    71 |
    public static final int
    72 | 73 |
    2
    74 |
    public static final int
    75 | 76 |
    4
    77 |
    public static final int
    78 | 79 |
    32
    80 |
    public static final int
    81 | 82 |
    16
    83 |
    public static final int
    84 | 85 |
    8
    86 |
    public static final int
    87 | 88 |
    64
    89 |
    public static final int
    90 | 91 |
    256
    92 |
    public static final int
    93 | 94 |
    1
    95 |
    96 |
  • 97 |
98 |
99 |
100 |
101 |
102 | 103 | 104 | -------------------------------------------------------------------------------- /docs/apidocs/de/unkrig/lfr/core/IntPredicate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IntPredicate 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 28 |
29 | 67 |
68 |
69 | 70 |
71 | 72 |

Interface IntPredicate

73 |
74 |
75 |
76 |
public interface IntPredicate
77 |
An optimization of Predicate<Integer> which saves the overhead of boxing and unboxing.
78 |
79 |
80 |
    81 | 82 |
  • 83 |
    84 |

    Method Summary

    85 |
    86 |
    87 |
    88 |
    89 |
    Modifier and Type
    90 |
    Method
    91 |
    Description
    92 |
    boolean
    93 |
    evaluate(int subject)
    94 |
    95 |
    Returns true iff the subject "qualifies", otherwise false.
    96 |
    97 |
    98 |
    99 |
    100 |
    101 |
  • 102 |
103 |
104 |
105 |
    106 | 107 |
  • 108 |
    109 |

    Method Details

    110 |
      111 |
    • 112 |
      113 |

      evaluate

      114 |
      boolean evaluate(int subject)
      115 |
      Returns true iff the subject "qualifies", otherwise false.
      116 |
      117 |
    • 118 |
    119 |
    120 |
  • 121 |
122 |
123 | 124 |
125 |
126 |
127 | 128 | 129 | -------------------------------------------------------------------------------- /docs/apidocs/de/unkrig/lfr/core/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | de.unkrig.lfr.core Class Hierarchy 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 24 |
25 | 48 |
49 |
50 |
51 |

Hierarchy For Package de.unkrig.lfr.core

52 | Package Hierarchies: 53 | 56 |
57 |
58 |

Class Hierarchy

59 | 76 |
77 |
78 |

Interface Hierarchy

79 | 92 |
93 |
94 |
95 |
96 | 97 | 98 | -------------------------------------------------------------------------------- /docs/apidocs/de/unkrig/ref4j/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | de.unkrig.ref4j 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 28 |
29 | 60 |
61 |
62 |
63 |

Package de.unkrig.ref4j

64 |
65 |
66 |
package de.unkrig.ref4j
67 |
68 |
    69 |
  • 70 |
    71 |
    72 |
    73 |
    74 |
    Class
    75 |
    Description
    76 | 77 |
    78 |
    A wrapper for Matcher.
    79 |
    80 | 81 |
     
    82 | 83 |
    84 |
    A facade or abstraction for various regular expression frameworks.
    85 |
    86 |
    87 |
    88 |
    89 |
  • 90 |
91 |
92 |
93 |
94 |
95 | 96 | 97 | -------------------------------------------------------------------------------- /docs/apidocs/de/unkrig/ref4j/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | de.unkrig.ref4j Class Hierarchy 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 24 |
25 | 48 |
49 |
50 |
51 |

Hierarchy For Package de.unkrig.ref4j

52 | Package Hierarchies: 53 | 56 |
57 |
58 |

Class Hierarchy

59 | 66 |
67 |
68 |

Interface Hierarchy

69 | 77 |
78 |
79 |
80 |
81 | 82 | 83 | -------------------------------------------------------------------------------- /docs/apidocs/element-list: -------------------------------------------------------------------------------- 1 | de.unkrig.lfr.core 2 | de.unkrig.ref4j 3 | -------------------------------------------------------------------------------- /docs/apidocs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Overview 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 24 |
25 | 48 |
49 |
50 |
51 |
Packages
52 |
53 |
Package
54 |
Description
55 | 56 |
57 |
A super-fast drop-in replacement for java.util.regex.
58 |
59 | 60 |
 
61 |
62 |
63 |
64 |
65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /docs/apidocs/jquery-ui.overrides.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | .ui-state-active, 27 | .ui-widget-content .ui-state-active, 28 | .ui-widget-header .ui-state-active, 29 | a.ui-button:active, 30 | .ui-button:active, 31 | .ui-button.ui-state-active:hover { 32 | /* Overrides the color of selection used in jQuery UI */ 33 | background: #F8981D; 34 | } 35 | -------------------------------------------------------------------------------- /docs/apidocs/legal/ADDITIONAL_LICENSE_INFO: -------------------------------------------------------------------------------- 1 | Please see ..\java.base\ADDITIONAL_LICENSE_INFO 2 | -------------------------------------------------------------------------------- /docs/apidocs/legal/ASSEMBLY_EXCEPTION: -------------------------------------------------------------------------------- 1 | Please see ..\java.base\ASSEMBLY_EXCEPTION 2 | -------------------------------------------------------------------------------- /docs/apidocs/legal/LICENSE: -------------------------------------------------------------------------------- 1 | Please see ..\java.base\LICENSE 2 | -------------------------------------------------------------------------------- /docs/apidocs/legal/jquery.md: -------------------------------------------------------------------------------- 1 | ## jQuery v3.5.1 2 | 3 | ### jQuery License 4 | ``` 5 | jQuery v 3.5.1 6 | Copyright JS Foundation and other contributors, https://js.foundation/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining 9 | a copy of this software and associated documentation files (the 10 | "Software"), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | ****************************************** 28 | 29 | The jQuery JavaScript Library v3.5.1 also includes Sizzle.js 30 | 31 | Sizzle.js includes the following license: 32 | 33 | Copyright JS Foundation and other contributors, https://js.foundation/ 34 | 35 | This software consists of voluntary contributions made by many 36 | individuals. For exact contribution history, see the revision history 37 | available at https://github.com/jquery/sizzle 38 | 39 | The following license applies to all parts of this software except as 40 | documented below: 41 | 42 | ==== 43 | 44 | Permission is hereby granted, free of charge, to any person obtaining 45 | a copy of this software and associated documentation files (the 46 | "Software"), to deal in the Software without restriction, including 47 | without limitation the rights to use, copy, modify, merge, publish, 48 | distribute, sublicense, and/or sell copies of the Software, and to 49 | permit persons to whom the Software is furnished to do so, subject to 50 | the following conditions: 51 | 52 | The above copyright notice and this permission notice shall be 53 | included in all copies or substantial portions of the Software. 54 | 55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 56 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 57 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 58 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 59 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 60 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 61 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 62 | 63 | ==== 64 | 65 | All files located in the node_modules and external directories are 66 | externally maintained libraries used by this software which have their 67 | own licenses; we recommend you read them, as their terms may differ from 68 | the terms above. 69 | 70 | ********************* 71 | 72 | ``` 73 | -------------------------------------------------------------------------------- /docs/apidocs/legal/jqueryUI.md: -------------------------------------------------------------------------------- 1 | ## jQuery UI v1.12.1 2 | 3 | ### jQuery UI License 4 | ``` 5 | Copyright jQuery Foundation and other contributors, https://jquery.org/ 6 | 7 | This software consists of voluntary contributions made by many 8 | individuals. For exact contribution history, see the revision history 9 | available at https://github.com/jquery/jquery-ui 10 | 11 | The following license applies to all parts of this software except as 12 | documented below: 13 | 14 | ==== 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining 17 | a copy of this software and associated documentation files (the 18 | "Software"), to deal in the Software without restriction, including 19 | without limitation the rights to use, copy, modify, merge, publish, 20 | distribute, sublicense, and/or sell copies of the Software, and to 21 | permit persons to whom the Software is furnished to do so, subject to 22 | the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be 25 | included in all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 30 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 31 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 32 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 33 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 34 | 35 | ==== 36 | 37 | Copyright and related rights for sample code are waived via CC0. Sample 38 | code is defined as all source code contained within the demos directory. 39 | 40 | CC0: http://creativecommons.org/publicdomain/zero/1.0/ 41 | 42 | ==== 43 | 44 | All files located in the node_modules and external directories are 45 | externally maintained libraries used by this software which have their 46 | own licenses; we recommend you read them, as their terms may differ from 47 | the terms above. 48 | 49 | ``` 50 | -------------------------------------------------------------------------------- /docs/apidocs/module-search-index.js: -------------------------------------------------------------------------------- 1 | moduleSearchIndex = [];updateSearchResults(); -------------------------------------------------------------------------------- /docs/apidocs/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Generated Documentation (Untitled) 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 |
20 | 23 |

index.html

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/apidocs/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Class Hierarchy 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 24 |
25 | 48 |
49 |
50 |
51 |

Hierarchy For All Packages

52 | Package Hierarchies: 53 | 57 |
58 |
59 |

Class Hierarchy

60 | 77 |
78 |
79 |

Interface Hierarchy

80 | 94 |
95 |
96 |
97 |
98 | 99 | 100 | -------------------------------------------------------------------------------- /docs/apidocs/package-search-index.js: -------------------------------------------------------------------------------- 1 | packageSearchIndex = [{"l":"All Packages","u":"allpackages-index.html"},{"l":"de.unkrig.lfr.core"},{"l":"de.unkrig.ref4j"}];updateSearchResults(); -------------------------------------------------------------------------------- /docs/apidocs/resources/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/resources/glass.png -------------------------------------------------------------------------------- /docs/apidocs/resources/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/resources/x.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-bg_glass_65_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-bg_glass_65_dadada_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/docs/apidocs/script-dir/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/script-dir/jquery-ui.structure.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.12.1 - 2018-12-06 2 | * http://jqueryui.com 3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */ 4 | 5 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0} -------------------------------------------------------------------------------- /docs/apidocs/script.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | var moduleSearchIndex; 27 | var packageSearchIndex; 28 | var typeSearchIndex; 29 | var memberSearchIndex; 30 | var tagSearchIndex; 31 | function loadScripts(doc, tag) { 32 | createElem(doc, tag, 'search.js'); 33 | 34 | createElem(doc, tag, 'module-search-index.js'); 35 | createElem(doc, tag, 'package-search-index.js'); 36 | createElem(doc, tag, 'type-search-index.js'); 37 | createElem(doc, tag, 'member-search-index.js'); 38 | createElem(doc, tag, 'tag-search-index.js'); 39 | } 40 | 41 | function createElem(doc, tag, path) { 42 | var script = doc.createElement(tag); 43 | var scriptElement = doc.getElementsByTagName(tag)[0]; 44 | script.src = pathtoroot + path; 45 | scriptElement.parentNode.insertBefore(script, scriptElement); 46 | } 47 | 48 | function show(tableId, selected, columns) { 49 | if (tableId !== selected) { 50 | document.querySelectorAll('div.' + tableId + ':not(.' + selected + ')') 51 | .forEach(function(elem) { 52 | elem.style.display = 'none'; 53 | }); 54 | } 55 | document.querySelectorAll('div.' + selected) 56 | .forEach(function(elem, index) { 57 | elem.style.display = ''; 58 | var isEvenRow = index % (columns * 2) < columns; 59 | elem.classList.remove(isEvenRow ? oddRowColor : evenRowColor); 60 | elem.classList.add(isEvenRow ? evenRowColor : oddRowColor); 61 | }); 62 | updateTabs(tableId, selected); 63 | } 64 | 65 | function updateTabs(tableId, selected) { 66 | document.querySelector('div#' + tableId +' .summary-table') 67 | .setAttribute('aria-labelledby', selected); 68 | document.querySelectorAll('button[id^="' + tableId + '"]') 69 | .forEach(function(tab, index) { 70 | if (selected === tab.id || (tableId === selected && index === 0)) { 71 | tab.className = activeTableTab; 72 | tab.setAttribute('aria-selected', true); 73 | tab.setAttribute('tabindex',0); 74 | } else { 75 | tab.className = tableTab; 76 | tab.setAttribute('aria-selected', false); 77 | tab.setAttribute('tabindex',-1); 78 | } 79 | }); 80 | } 81 | 82 | function switchTab(e) { 83 | var selected = document.querySelector('[aria-selected=true]'); 84 | if (selected) { 85 | if ((e.keyCode === 37 || e.keyCode === 38) && selected.previousSibling) { 86 | // left or up arrow key pressed: move focus to previous tab 87 | selected.previousSibling.click(); 88 | selected.previousSibling.focus(); 89 | e.preventDefault(); 90 | } else if ((e.keyCode === 39 || e.keyCode === 40) && selected.nextSibling) { 91 | // right or down arrow key pressed: move focus to next tab 92 | selected.nextSibling.click(); 93 | selected.nextSibling.focus(); 94 | e.preventDefault(); 95 | } 96 | } 97 | } 98 | 99 | var updateSearchResults = function() {}; 100 | 101 | function indexFilesLoaded() { 102 | return moduleSearchIndex 103 | && packageSearchIndex 104 | && typeSearchIndex 105 | && memberSearchIndex 106 | && tagSearchIndex; 107 | } 108 | 109 | // Workaround for scroll position not being included in browser history (8249133) 110 | document.addEventListener("DOMContentLoaded", function(e) { 111 | var contentDiv = document.querySelector("div.flex-content"); 112 | window.addEventListener("popstate", function(e) { 113 | if (e.state !== null) { 114 | contentDiv.scrollTop = e.state; 115 | } 116 | }); 117 | window.addEventListener("hashchange", function(e) { 118 | history.replaceState(contentDiv.scrollTop, document.title); 119 | }); 120 | contentDiv.addEventListener("scroll", function(e) { 121 | var timeoutID; 122 | if (!timeoutID) { 123 | timeoutID = setTimeout(function() { 124 | history.replaceState(contentDiv.scrollTop, document.title); 125 | timeoutID = null; 126 | }, 100); 127 | } 128 | }); 129 | if (!location.hash) { 130 | history.replaceState(contentDiv.scrollTop, document.title); 131 | } 132 | }); 133 | -------------------------------------------------------------------------------- /docs/apidocs/serialized-form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Serialized Form 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 24 |
25 | 48 |
49 |
50 |
51 |

Serialized Form

52 |
53 | 117 |
118 |
119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /docs/apidocs/tag-search-index.js: -------------------------------------------------------------------------------- 1 | tagSearchIndex = [{"l":"Constant Field Values","h":"","u":"constant-values.html"},{"l":"Serialized Form","h":"","u":"serialized-form.html"}];updateSearchResults(); -------------------------------------------------------------------------------- /docs/apidocs/type-search-index.js: -------------------------------------------------------------------------------- 1 | typeSearchIndex = [{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"de.unkrig.lfr.core","l":"CharacterClass"},{"p":"de.unkrig.lfr.core","l":"Matcher.CompiledReplacement"},{"p":"de.unkrig.lfr.core","l":"Grapheme"},{"p":"de.unkrig.lfr.core","l":"IntPredicate"},{"p":"de.unkrig.lfr.core","l":"Sequences.LiteralString"},{"p":"de.unkrig.lfr.core","l":"Matcher"},{"p":"de.unkrig.ref4j","l":"Matcher"},{"p":"de.unkrig.lfr.core","l":"Pattern"},{"p":"de.unkrig.ref4j","l":"Pattern"},{"p":"de.unkrig.lfr.core","l":"PatternFactory"},{"p":"de.unkrig.ref4j","l":"PatternFactory"},{"p":"de.unkrig.lfr.core","l":"ReverseCharSequence"},{"p":"de.unkrig.lfr.core","l":"Sequences"}];updateSearchResults(); -------------------------------------------------------------------------------- /docs/generate_javadoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e; 4 | 5 | JAVA_HOME=C:/dev/Java/jdk-17.0.2+8; 6 | 7 | cp="\ 8 | ../commons-lang/target/classes;\ 9 | ../commons-util/target/classes;\ 10 | ../commons-nullanalysis/target/classes;\ 11 | ../commons-text/target/classes"; 12 | 13 | # -link https://docs.oracle.com/javase/11/docs/api/ \ 14 | $JAVA_HOME/bin/javadoc \ 15 | -sourcepath "../lfr-core/src/main/java;../ref4j/src/main/java" \ 16 | -classpath "$cp" \ 17 | -d apidocs \ 18 | -Xdoclint:none \ 19 | -J-Dhttp.proxyHost=localhost \ 20 | -J-Dhttp.proxyPort=999 \ 21 | -J-Dhttps.proxyHost=localhost \ 22 | -J-Dhttps.proxyPort=999 \ 23 | -subpackages \ 24 | de.unkrig.lfr.core \ 25 | de.unkrig.ref4j \ 26 | ; 27 | -------------------------------------------------------------------------------- /lfr-core/.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lfr-core/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lfr-core/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /lfr-core/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | lfr-core 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | net.sf.eclipsecs.core.CheckstyleBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | net.sf.eclipsecs.core.CheckstyleNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /lfr-core/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /lfr-core/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_profile=_Eclipse [spaces-only] 3 | formatter_settings_version=12 4 | -------------------------------------------------------------------------------- /lfr-core/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /lfr-core/.settings/org.jboss.ide.eclipse.as.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.jboss.ide.eclipse.as.core.singledeployable.deployableList= 3 | -------------------------------------------------------------------------------- /lfr-core/launch/lfr-core jre11.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /lfr-core/launch/lfr-core jre17.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /lfr-core/launch/lfr-core jre8.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /lfr-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | lfr-core 5 | 6 | Lightning-fast regular expressions 7 | 8 | 9 | 10 | de.unkrig.commons 11 | commons-text 12 | 13 | 14 | junit 15 | junit 16 | test 17 | 18 | 19 | de.unkrig.lfr 20 | ref4j 21 | ${project.parent.version} 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-jar-plugin 30 | 31 | 32 | 33 | org.apache.maven.plugins 34 | maven-source-plugin 35 | 36 | 37 | 38 | org.apache.maven.plugins 39 | maven-javadoc-plugin 40 | 41 | 42 | 43 | org.sonatype.plugins 44 | nexus-staging-maven-plugin 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | have_gpg 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-gpg-plugin 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | de.unkrig.lfr 67 | lfr-parent 68 | 1.2.1-SNAPSHOT 69 | ../lfr-parent 70 | 71 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/CharacterClass.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | import de.unkrig.commons.lang.protocol.Consumer; 30 | 31 | /** 32 | * A {@link CompositeSequence} that implements {@link #matches(MatcherImpl)} by applying {@link 33 | * #matches(int)} onto itself. 34 | */ 35 | public abstract 36 | class CharacterClass extends CompositeSequence { 37 | 38 | public 39 | CharacterClass() { 40 | super( 41 | 1, // minMatchLengthWithoutNext 42 | 2 // maxMatchLengthWithoutNext 43 | ); 44 | } 45 | 46 | public 47 | CharacterClass(int matchLengthWithoutNext) { 48 | super(matchLengthWithoutNext, matchLengthWithoutNext); 49 | } 50 | 51 | public 52 | CharacterClass(int minMatchLengthWithoutNext, int maxMatchLengthWithoutNext) { 53 | super(minMatchLengthWithoutNext, maxMatchLengthWithoutNext); 54 | } 55 | 56 | @Override public boolean 57 | matches(MatcherImpl matcher) { 58 | 59 | if (matcher.offset >= matcher.regionEnd) { 60 | matcher.hitEnd = true; 61 | return false; 62 | } 63 | 64 | int savedOffset = matcher.offset; 65 | int cp = matcher.readChar(); 66 | 67 | if (!this.matches(cp)) { 68 | matcher.offset= savedOffset; 69 | return false; 70 | } 71 | 72 | return this.next.matches(matcher); 73 | } 74 | 75 | @Override public int 76 | find(MatcherImpl matcher) { 77 | 78 | while (matcher.offset < matcher.regionEnd) { 79 | 80 | int startOfMatch = matcher.offset; 81 | 82 | int cp = matcher.readChar(); 83 | 84 | if (this.matches(cp)) { 85 | 86 | // See if the rest of the pattern matches. 87 | int savedOffset = matcher.offset; 88 | if (this.next.matches(matcher)) return startOfMatch; 89 | matcher.offset= savedOffset; 90 | } 91 | } 92 | 93 | matcher.hitEnd = true; 94 | return -1; 95 | } 96 | 97 | /** 98 | * @return Whether the codePoint matches this character class 99 | */ 100 | public abstract boolean 101 | matches(int codePoint); 102 | 103 | /** 104 | * {@link #matches(int)} is guaranteed to return {@code false} for all subjects smaller than {@link #lowerBound()}. 105 | */ 106 | @SuppressWarnings("static-method") public int 107 | lowerBound() { return 0; } 108 | 109 | /** 110 | * {@link #matches(int)} is guaranteed to return {@code false} for all subjects greater than or equal to {@link 111 | * #upperBound()}. 112 | */ 113 | @SuppressWarnings("static-method") public int 114 | upperBound() { return Integer.MAX_VALUE; } 115 | 116 | /** 117 | * @return The number of values for which {@link #matches(int)} returns {@code true}, or more 118 | */ 119 | @SuppressWarnings("static-method") public int 120 | sizeBound() { return Integer.MAX_VALUE; } 121 | 122 | @Override protected void 123 | checkWithoutNext(int offset, Consumer result) { 124 | 125 | if (this.upperBound() - this.lowerBound() > 100) { 126 | result.consume(-1); 127 | return; 128 | } 129 | 130 | for (int cp = this.lowerBound(); cp < this.upperBound(); cp++) { 131 | if (this.matches(cp)) { 132 | for (int cp2 : new int[] { cp, Character.toUpperCase(cp), Character.toLowerCase(cp) }) { 133 | char[] chars = Character.toChars(cp2); 134 | if (offset < chars.length) result.consume((int) chars[offset]); 135 | } 136 | } 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/CompositeSequence.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | import de.unkrig.commons.lang.protocol.Consumer; 30 | import de.unkrig.commons.util.ArrayUtil; 31 | 32 | /** 33 | * An {@link Sequence} that implements {@link #concat(Sequence)} by setting up a linked list of {@link Sequence}es. 34 | *

35 | * Notice that implementations' {@link #matches(MatcherImpl)} methods must always honor the {@link #next}! 36 | *

37 | */ 38 | abstract 39 | class CompositeSequence extends Sequence { 40 | 41 | /** 42 | * Reference to the "next" sequence. 43 | */ 44 | Sequence next; 45 | 46 | /** 47 | * This sequence (excluding the {@link #next} sequence) will match at least that many characters. E.g. 48 | * ".{3,5}" has a {@link #minMatchLengthWithoutNext} of three. 49 | */ 50 | private final int minMatchLengthWithoutNext; 51 | 52 | /** 53 | * This sequence (excluding the {@link #next} sequence) will match at most that many characters. E.g. 54 | * ".{,3}" has a {@link #maxMatchLengthWithoutNext} of six. 55 | */ 56 | private final int maxMatchLengthWithoutNext; 57 | 58 | CompositeSequence(int matchLengthWithoutNext) { 59 | super(matchLengthWithoutNext, matchLengthWithoutNext); 60 | this.next = Sequences.TERMINAL; 61 | this.minMatchLengthWithoutNext = matchLengthWithoutNext; 62 | this.maxMatchLengthWithoutNext = matchLengthWithoutNext; 63 | } 64 | 65 | CompositeSequence( 66 | int minMatchLengthWithoutNext, 67 | int maxMatchLengthWithoutNext 68 | ) { 69 | super(minMatchLengthWithoutNext, maxMatchLengthWithoutNext); 70 | this.next = Sequences.TERMINAL; 71 | this.minMatchLengthWithoutNext = minMatchLengthWithoutNext; 72 | this.maxMatchLengthWithoutNext = maxMatchLengthWithoutNext; 73 | } 74 | 75 | @Override public Sequence 76 | concat(Sequence that) { 77 | 78 | this.next = this.next.concat(that); 79 | 80 | this.minMatchLength = Sequences.add(this.minMatchLengthWithoutNext, this.next.minMatchLength); 81 | this.maxMatchLength = Sequences.add(this.maxMatchLengthWithoutNext, this.next.maxMatchLength); 82 | 83 | // Join adjacent MultivalentSequences. 84 | if (this instanceof MultivalentSequence) { 85 | MultivalentSequence ms1 = (MultivalentSequence) this; 86 | CompositeSequence cs1 = (CompositeSequence) this; 87 | 88 | if (cs1.next instanceof MultivalentSequence) { 89 | MultivalentSequence ms2 = (MultivalentSequence) cs1.next; 90 | CompositeSequence cs2 = (CompositeSequence) cs1.next; 91 | 92 | return Sequences.multivalentSequence(ArrayUtil.append( 93 | ms1.getNeedle(), 94 | ms2.getNeedle() 95 | )).concat(cs2.next); 96 | } 97 | } 98 | 99 | return this; 100 | } 101 | 102 | @Override void 103 | check(int offset, Consumer result) { 104 | 105 | if (offset < this.maxMatchLengthWithoutNext) this.checkWithoutNext(offset, result); 106 | 107 | // int limit = offset - this.minMatchLengthWithoutNext; 108 | if (offset >= this.minMatchLengthWithoutNext) { 109 | for (int i = this.minMatchLengthWithoutNext; i <= this.maxMatchLengthWithoutNext && i <= offset; i++) { 110 | this.next.check(offset - i, result); 111 | } 112 | } 113 | } 114 | 115 | /** 116 | * Same as {@link #check(int, Consumer)}, but ignores the {@link #next} sequence. 117 | * 118 | * @param offset 0 ... {@code (}{@link #maxMatchLengthWithoutNext} {@code - 1)} 119 | */ 120 | protected void 121 | checkWithoutNext(int offset, Consumer result) { 122 | if (this.maxMatchLengthWithoutNext > 0) result.consume(-1); 123 | } 124 | 125 | /** 126 | * @return A human-readable form of {@code this} sequence, but without the {@link #next} sequence 127 | */ 128 | protected abstract String 129 | toStringWithoutNext(); 130 | 131 | @Override public String 132 | toString() { 133 | return ( 134 | this.next == Sequences.TERMINAL 135 | ? this.toStringWithoutNext() 136 | : this.toStringWithoutNext() + " . " + this.next.toString() 137 | ); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/Grapheme.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2019, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | import de.unkrig.commons.lang.AssertionUtil; 30 | import de.unkrig.commons.lang.OptionalMethods; 31 | import de.unkrig.commons.lang.OptionalMethods.MethodWrapper2; 32 | 33 | public final 34 | class Grapheme { 35 | 36 | static { AssertionUtil.enableAssertionsForThisClass(); } 37 | 38 | private Grapheme() {} 39 | 40 | private static final MethodWrapper2 41 | GRAPHEME__IS_BOUNDARY = OptionalMethods.get2( 42 | "Graphemes only available in Java 9+", // message 43 | null, // classLoader 44 | "java.util.regex.Grapheme", // declaringClassName 45 | "isBoundary", // methodName 46 | int.class, // parameterType1 47 | int.class // parameterType2 48 | ); 49 | 50 | public static boolean 51 | isBoundary(int cp0, int cp1) { 52 | Boolean result = GRAPHEME__IS_BOUNDARY.invoke(null, cp0, cp1); 53 | assert result != null; 54 | return result; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/IntPredicate.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | import de.unkrig.commons.lang.protocol.Predicate; 30 | 31 | /** 32 | * An optimization of {@link Predicate Predicate}{@code } which saves the overhead of boxing and unboxing. 33 | */ 34 | public 35 | interface IntPredicate { 36 | 37 | /** 38 | * Returns {@code true} iff the subject "qualifies", otherwise {@code false}. 39 | */ 40 | boolean evaluate(int subject); 41 | } 42 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/MultivalentCharClass.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | import java.util.Arrays; 30 | import java.util.Set; 31 | 32 | /** 33 | * A specialization of {@link MultivalentCharacterClass} that is slightly faster because it saves the overhead of 34 | * decoding surrogate pairs, but works only for BMP (one-char) code points. 35 | */ 36 | class MultivalentCharClass extends MultivalentCharacterClass implements MultivalentSequence { 37 | 38 | MultivalentCharClass(Set codePoints) { super(codePoints); } 39 | 40 | @Override public char[][] 41 | getNeedle() { 42 | 43 | char[][] result = new char[1][this.codePoints.size()]; 44 | 45 | int i = 0; 46 | for (int cp : this.codePoints) result[0][i++] = (char) cp; 47 | 48 | Arrays.sort(result[0]); 49 | 50 | return result; 51 | } 52 | 53 | @Override public boolean 54 | matches(MatcherImpl matcher) { 55 | 56 | int o = matcher.offset; 57 | 58 | if (o >= matcher.regionEnd) { 59 | matcher.hitEnd = true; 60 | return false; 61 | } 62 | 63 | char c = matcher.subject.charAt(o++); 64 | 65 | if (!this.matches(c)) return false; 66 | 67 | matcher.offset = o; 68 | return this.next.matches(matcher); 69 | } 70 | 71 | /** 72 | * Optimized version of {@link #find(MatcherImpl)} 73 | */ 74 | @Override public int 75 | find(MatcherImpl matcher) { 76 | 77 | int o = matcher.offset; 78 | 79 | FIND: 80 | while (o < matcher.regionEnd) { 81 | 82 | // Find the next occurrence of the literal char. 83 | for (;; o++) { 84 | if (o >= matcher.regionEnd) break FIND; 85 | if (this.matches(matcher.subject.charAt(o))) break; 86 | } 87 | 88 | // See if the rest of the pattern matches. 89 | matcher.offset = o + 1; 90 | if (this.next.matches(matcher)) return o; 91 | 92 | // Rest of pattern didn't match; continue right behind the character match. 93 | o++; 94 | } 95 | 96 | matcher.hitEnd = true; 97 | return -1; 98 | } 99 | 100 | @Override public int sizeBound() { return 1; } 101 | 102 | @Override protected String 103 | toStringWithoutNext() { return "oneOfManyChars(" + this.codePoints + ")"; } 104 | } 105 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/MultivalentCharacterClass.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | import java.util.Set; 32 | 33 | import de.unkrig.commons.lang.protocol.Consumer; 34 | import de.unkrig.commons.util.ArrayUtil; 35 | 36 | /** 37 | * A specialization of {@link CharacterClass} that matches a (typically relatively small) set of code points. 38 | */ 39 | class MultivalentCharacterClass extends CharacterClass { 40 | 41 | protected final Set codePoints; 42 | protected final int lowerBound, upperBound, sizeBound; 43 | 44 | /** 45 | * @param codePoints The set of code points that designate a positive match e.g. "{ 'a', 'A' }" 46 | */ 47 | MultivalentCharacterClass(Set codePoints) { 48 | super( 49 | MultivalentCharacterClass.minCharCountOf(codePoints), 50 | MultivalentCharacterClass.maxCharCountOf(codePoints) 51 | ); 52 | this.codePoints = codePoints; 53 | 54 | this.lowerBound = MultivalentCharacterClass.min(codePoints); 55 | this.upperBound = MultivalentCharacterClass.max(codePoints) + 1; 56 | this.sizeBound = codePoints.size(); 57 | } 58 | 59 | @Override public boolean 60 | matches(int cp) { return this.codePoints.contains(cp); } 61 | 62 | @Override public int lowerBound() { return this.lowerBound; } 63 | @Override public int upperBound() { return this.upperBound; } 64 | @Override public int sizeBound() { return this.sizeBound; } 65 | 66 | @Override public Sequence 67 | concat(Sequence that) { 68 | 69 | Sequence result = super.concat(that); 70 | if (result != this) return result; 71 | 72 | if ( 73 | this.minMatchLength == this.maxMatchLength 74 | && this.next instanceof MultivalentCharacterClass 75 | ) { 76 | MultivalentCharacterClass 77 | next2 = (MultivalentCharacterClass) this.next; 78 | 79 | if (next2.minMatchLength == next2.maxMatchLength) { 80 | 81 | List chars1 = new ArrayList(this.codePoints.size()); 82 | for (int cp : this.codePoints) chars1.add(Character.toChars(cp)); 83 | 84 | List chars2 = new ArrayList(next2.codePoints.size()); 85 | for (int cp : next2.codePoints) chars2.add(Character.toChars(cp)); 86 | 87 | return Sequences.multivalentSequence(ArrayUtil.append( 88 | ArrayUtil.mirror(chars1.toArray(new char[chars1.size()][])), 89 | ArrayUtil.mirror(chars2.toArray(new char[chars2.size()][])) 90 | )).concat(next2.next); 91 | } 92 | } 93 | 94 | return this; 95 | } 96 | 97 | @Override protected void 98 | checkWithoutNext(int offset, Consumer result) { 99 | for (int cp : this.codePoints) { 100 | char[] chars = Character.toChars(cp); 101 | if (offset < chars.length) result.consume((int) chars[offset]); 102 | } 103 | } 104 | 105 | @Override protected String 106 | toStringWithoutNext() { return "oneOfManyCodePoints(" + this.codePoints + ")"; } 107 | 108 | private static int 109 | min(Set set) { 110 | int result = Integer.MAX_VALUE; 111 | for (int i : set) { 112 | if (i < result) result = i; 113 | } 114 | return result; 115 | } 116 | 117 | private static int 118 | max(Set set) { 119 | int result = Integer.MIN_VALUE; 120 | for (int i : set) { 121 | if (i > result) result = i; 122 | } 123 | return result; 124 | } 125 | 126 | private static int 127 | minCharCountOf(Set codePoints) { 128 | for (int cp : codePoints) { 129 | if (Character.charCount(cp) == 1) return 1; 130 | } 131 | return 2; 132 | } 133 | 134 | private static int 135 | maxCharCountOf(Set codePoints) { 136 | for (int cp : codePoints) { 137 | if (Character.charCount(cp) == 2) return 2; 138 | } 139 | return 1; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/MultivalentSequence.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | /** 30 | * A sequence of fixed length, where each position is linked with a (typically small) set of {@code char}s. 31 | * These sets of chars are also called "the needle", as a metaphor for a needle that is to be found in a haystack. 32 | *

33 | * Examples for multivalent sequences: 34 | *

35 | *
36 | *
"abc"
37 | *
"abc", case-insensitive
38 | *
"a[bc]d" (match length is 3)
39 | *
"\s" (whitespace characters are all in the BMP, and are a small set)
40 | *
"abc|def" (both alternatives have the same length)
41 | *
"a\x{10000}|def" (both alternatives have length 3)
42 | *
43 | *

44 | * The following are not multivalent sequences: 45 | *

46 | *
47 | *
"[b\x{10000}]" ("b" has length 1, and "\x{10000}" has length 2)
48 | *
"\S" (non-whitespace characters; have different lengths)
49 | *
\p{IsAlphabetic} (have different lengths)
50 | *
\p{InGreek} (not a small set)
51 | *
A? (length is not fixed)
52 | *
.* (length is not fixed)
53 | *
54 | * 55 | * @see #getNeedle() 56 | */ 57 | interface MultivalentSequence { 58 | 59 | /** 60 | * Returns the character sets that represent a match, e.g. "{ { 'a', 'A' }, { 'b', 'B' }, { 'c', 'C' } 61 | * }". 62 | *

63 | * Notice that, other than in the example above, {@code getNeedle()[n].length} is often different for different 64 | * values of {@code n}. 65 | *

66 | */ 67 | char[][] 68 | getNeedle(); 69 | } 70 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/ReverseCharSequence.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.lfr.core; 28 | 29 | /** 30 | * @author Arno 31 | * 32 | */ 33 | public abstract 34 | class ReverseCharSequence implements CharSequence { 35 | 36 | /** 37 | * @return The original char sequence; actually "the reverse of the reverse" 38 | */ 39 | protected abstract CharSequence 40 | original(); 41 | 42 | /** 43 | * @return Depending on the subject, {@link #reverseByCopy(CharSequence)} or {@link #reverseInPlace(CharSequence)} 44 | */ 45 | public static CharSequence 46 | reverse(CharSequence subject) { 47 | return ( 48 | subject.length() <= 10 49 | ? ReverseCharSequence.reverseByCopy(subject) 50 | : ReverseCharSequence.reverseInPlace(subject) 51 | ); 52 | } 53 | 54 | /** 55 | * Returns a string that is the "logical reverse" of the cs, i.e. surrogate pairs and CR-LF pairs are 56 | * not reversed. 57 | */ 58 | public static String 59 | reverseByCopy(CharSequence subject) { 60 | 61 | StringBuilder sb = new StringBuilder(subject).reverse(); 62 | 63 | // Un-reverse CR-LF sequences. 64 | for (int i = sb.length() - 2; i >= 0; i--) { 65 | if (sb.charAt(i) == '\n' && sb.charAt(i + 1) == '\r') { 66 | sb.setCharAt(i, '\r'); 67 | sb.setCharAt(i + 1, '\n'); 68 | i--; 69 | } 70 | } 71 | 72 | return sb.toString(); 73 | } 74 | 75 | /** 76 | * Returns a {@link CharSequence} that is the "logical reverse" of the cs, i.e. surrogate pairs and 77 | * CR-LF pairs are not reversed. The returned {@link CharSequence} is based on the original, thus, the 78 | * behavior of the returned {@link CharSequence} is undefined if the original changes. 79 | */ 80 | public static CharSequence 81 | reverseInPlace(final CharSequence subject) { 82 | 83 | if (subject instanceof ReverseCharSequence) return ((ReverseCharSequence) subject).original(); 84 | 85 | return new ReverseCharSequence() { 86 | 87 | final int len = subject.length(); 88 | final int lenm1 = this.len - 1; 89 | 90 | // IMPLEMENT ReverseCharSequence 91 | 92 | @Override protected CharSequence 93 | original() { return subject; } 94 | 95 | // IMPLEMENT CharSequence 96 | 97 | @Override public int 98 | length() { return this.len; } 99 | 100 | @Override public char 101 | charAt(int offset) { 102 | 103 | // Reverse the offset. 104 | offset = this.lenm1 - offset; 105 | 106 | char c = subject.charAt(offset); 107 | 108 | // Un-reverse CR-LF sequences. 109 | if (c == '\r' && offset < this.lenm1 && subject.charAt(offset + 1) == '\n') return '\n'; 110 | if (c == '\n' && offset > 0 && subject.charAt(offset - 1) == '\r') return '\r'; 111 | 112 | // Un-reverse high-surrogate-low-surrogate. 113 | char c2; 114 | if ( 115 | Character.isHighSurrogate(c) 116 | && offset < this.lenm1 117 | && Character.isLowSurrogate((c2 = subject.charAt(offset + 1))) 118 | ) return c2; 119 | if ( 120 | Character.isLowSurrogate(c) 121 | && offset > 0 122 | && Character.isHighSurrogate((c2 = subject.charAt(offset - 1))) 123 | ) return c2; 124 | 125 | return c; 126 | } 127 | 128 | @Override public CharSequence 129 | subSequence(int start, int end) { return ReverseCharSequence.subSequence(subject, start, end); } 130 | 131 | @Override public String 132 | toString() { 133 | StringBuilder sb = new StringBuilder(this.len); 134 | for (int i = 0; i < this.len;) { 135 | int cp = Character.codePointAt(this, i); 136 | sb.appendCodePoint(cp); 137 | i += Character.charCount(cp); 138 | } 139 | return sb.toString(); 140 | } 141 | }; 142 | } 143 | 144 | /** 145 | * Trivial implementation of a "subsequence". 146 | */ 147 | private static CharSequence 148 | subSequence(final CharSequence cs, final int start, final int end) { 149 | 150 | return new CharSequence() { 151 | 152 | @Override public int 153 | length() { return end - start; } 154 | 155 | @Override public char 156 | charAt(int index) { return cs.charAt(start + index); } 157 | 158 | @Override public CharSequence 159 | subSequence(int start2, int end2) { 160 | return ReverseCharSequence.subSequence(cs, start + start2, start + end2); 161 | } 162 | 163 | @Override public String 164 | toString() { 165 | char[] ca = new char[end - start]; 166 | for (int i = start; i < end; i++) ca[i] = cs.charAt(start + i); 167 | return new String(ca); 168 | } 169 | }; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /lfr-core/src/main/java/de/unkrig/lfr/core/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2016, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | /** 28 | * A super-fast drop-in replacement for {@code java.util.regex}. 29 | */ 30 | @NotNullByDefault 31 | package de.unkrig.lfr.core; 32 | 33 | import de.unkrig.commons.nullanalysis.NotNullByDefault; 34 | -------------------------------------------------------------------------------- /lfr-core/src/main/javadoc/overview.html: -------------------------------------------------------------------------------- 1 | 2 |

3 | Lightning-fast Regular Expressions ("LFR") is a 99.9%-complete reimplementation of java.util.regex 4 | ("JUR") with better match() and find() performance, and some extra features. 5 |

6 | 7 |

8 | The project home page is on GITHUB. 9 |

10 | 11 | -------------------------------------------------------------------------------- /lfr-core/src/main/javadoc/package-lists/de.unkrig.commons/commons-text/package-list: -------------------------------------------------------------------------------- 1 | de.unkrig.commons.text 2 | de.unkrig.commons.text.expression 3 | de.unkrig.commons.text.json 4 | de.unkrig.commons.text.parser 5 | de.unkrig.commons.text.pattern 6 | de.unkrig.commons.text.scanner 7 | de.unkrig.commons.text.xml 8 | -------------------------------------------------------------------------------- /lfr-core/src/main/resources/META-INF/services/de.unkrig.ref4j.PatternFactory: -------------------------------------------------------------------------------- 1 | 2 | # The "lightening-fast regular expressions" implementation of de.unkrig.ref4j.PatternFactory: 3 | de.unkrig.lfr.core.PatternFactory 4 | de.unkrig.lfr.core.PatternFactory.instanceField = INSTANCE 5 | -------------------------------------------------------------------------------- /lfr-core/src/test/java/test/OracleEssentials.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2016, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package test; 28 | 29 | import de.unkrig.commons.lang.ExceptionUtil; 30 | import de.unkrig.commons.nullanalysis.Nullable; 31 | import de.unkrig.ref4j.Matcher; 32 | import de.unkrig.ref4j.Pattern; 33 | import de.unkrig.ref4j.PatternFactory; 34 | 35 | public 36 | class OracleEssentials extends ParameterizedWithPatternFactory { 37 | 38 | public 39 | OracleEssentials(PatternFactory patternFactory) { super(patternFactory); } 40 | 41 | /** 42 | * Shorthand for "{@link #harnessFull(String, String, int, Integer, int, Boolean, Boolean) harness(regex, subject, 43 | * 0, null, 0, null, null)}". 44 | */ 45 | public void 46 | harnessFull(String regex, String subject) { this.harnessFull(regex, subject, 0, null, 0, null, null); } 47 | 48 | /** 49 | * Shorthand for "{@link #harnessFull(String, String, int, Integer, int, Boolean, Boolean) harness(regex, subject, 50 | * flags, null, 0, null, null)}". 51 | */ 52 | public void 53 | harnessFull(String regex, String subject, int flags) { 54 | this.harnessFull(regex, subject, flags, null, 0, null, null); 55 | } 56 | 57 | /** 58 | * Shorthand for "{@link #harnessFull(String, String, int, Integer, int, Boolean, Boolean) harness(regex, subject, 59 | * flags, regionStart, regionEnd, null, null)}". 60 | */ 61 | public void 62 | harnessFull(String regex, String subject, int flags, int regionStart, int regionEnd) { 63 | this.harnessFull(regex, subject, flags, regionStart, regionEnd, null, null); 64 | } 65 | 66 | /** 67 | * Shorthand for "{@link #harnessFull(String, String, int, Integer, int, Boolean, Boolean) harness(regex, subject, 68 | * flags, regionStart, regionEnd, transparentBounds, null)}". 69 | */ 70 | public void 71 | harnessFull(String regex, String subject, int flags, int regionStart, int regionEnd, boolean transparentBounds) { 72 | this.harnessFull(regex, subject, flags, regionStart, regionEnd, transparentBounds, null); 73 | } 74 | 75 | /** 76 | * Verifies that {@link PatternFactory#compile(String, int)}, {@link Matcher#lookingAt()}, {@link Matcher#matches()} and 77 | * {@link Matcher#find()} don't throw any exceptions. 78 | * 79 | * @param flags Regex compilation flags, see {@link java.util.regex.Pattern#compile(String, int)} 80 | * @param regionStart Optional: The non-default region to use for the matcher; see {@link 81 | * java.util.regex.Matcher#region(int, int)} 82 | * @param regionEnd Honored only when regionStart {@code != null} 83 | * @param transparentBounds Optional: Call {@link java.util.regex.Matcher#useTransparentBounds(boolean)} 84 | * @param anchoringBounds Optional: Call {@link java.util.regex.Matcher#useAnchoringBounds(boolean)} 85 | */ 86 | public void 87 | harnessFull( 88 | String regex, 89 | final String subject, 90 | int flags, 91 | @Nullable Integer regionStart, 92 | int regionEnd, 93 | @Nullable Boolean transparentBounds, 94 | @Nullable Boolean anchoringBounds 95 | ) { 96 | 97 | Pattern pattern = this.patternFactory.compile(regex, flags); 98 | 99 | Matcher m = pattern.matcher(subject); 100 | 101 | if (regionStart != null) m.region(regionStart, regionEnd); 102 | if (transparentBounds != null) m.useTransparentBounds(transparentBounds); 103 | if (anchoringBounds != null) m.useAnchoringBounds(anchoringBounds); 104 | 105 | m.lookingAt(); 106 | 107 | m.matches(); 108 | 109 | // "matches()", if unsuccessful, leaves the matcher in a very strange state: The next invocation of "find()" 110 | // (a few lines below), will will NOT start at the beginning of the region, but where "lookingAt()" left off!? 111 | // The simple workaround is to reset the matcher here. 112 | m.reset(); 113 | 114 | int matchNumber = 1; 115 | try { 116 | while (m.find()) matchNumber++; 117 | } catch (RuntimeException re) { 118 | throw ExceptionUtil.wrap("find(): Match #" + matchNumber, re); 119 | } catch (Error e) { // SUPPRESS CHECKSTYLE IllegalCatch 120 | throw ExceptionUtil.wrap("find(): Match #" + matchNumber, e); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /lfr-core/src/test/java/test/ParameterizedWithPatternFactory.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2019, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package test; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | import org.junit.runners.Parameterized.Parameters; 33 | 34 | import de.unkrig.ref4j.PatternFactory; 35 | 36 | public abstract 37 | class ParameterizedWithPatternFactory { 38 | 39 | protected final PatternFactory patternFactory; 40 | 41 | public 42 | ParameterizedWithPatternFactory(PatternFactory patternFactory) { this.patternFactory = patternFactory; } 43 | 44 | @Parameters(name = "PatternFactory={1}") public static Iterable 45 | patternFactories() throws Exception { 46 | 47 | List result = new ArrayList(); 48 | 49 | for (PatternFactory pf : new PatternFactory[] { 50 | de.unkrig.lfr.core.PatternFactory.INSTANCE, 51 | de.unkrig.ref4j.jur.PatternFactory.INSTANCE, 52 | }) result.add(new Object[] { pf, pf.getId() }); 53 | 54 | return result; 55 | } 56 | 57 | public boolean 58 | isLfr() { return this.patternFactory.getId().equals("de.unkrig.lfr"); } 59 | } 60 | -------------------------------------------------------------------------------- /lfr-core/src/test/java/test/PerformanceMeasurement.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package test; 28 | 29 | import java.util.Arrays; 30 | import java.util.Locale; 31 | 32 | import de.unkrig.commons.lang.protocol.ConsumerWhichThrows; 33 | import de.unkrig.commons.lang.protocol.NoException; 34 | import de.unkrig.commons.lang.protocol.TransformerUtil; 35 | import de.unkrig.commons.lang.protocol.TransformerWhichThrows; 36 | 37 | /** 38 | * A framework for reliable measurement of the CPU time consumed by a piece of code. 39 | */ 40 | public final 41 | class PerformanceMeasurement { 42 | 43 | private PerformanceMeasurement() {} 44 | 45 | private static final int REP2 = 1000; 46 | 47 | /** 48 | * Lets execute consume each input (many times), measures the user cpu times, and prints 49 | * them to {@code System.out}. 50 | */ 51 | public static void 52 | probe(String message, T[] inputs, final ConsumerWhichThrows execute) { 53 | PerformanceMeasurement.probe(message, inputs, TransformerUtil.identity(), execute); 54 | } 55 | 56 | /** 57 | * Transforms each of the inputs with the prepare transformer, then lets execute 58 | * consume each transformed input (many times), measures the user cpu times, and prints them to {@code 59 | * System.out}. 60 | */ 61 | public static void 62 | probe( 63 | String message, 64 | T1[] inputs, 65 | final TransformerWhichThrows prepare, 66 | final ConsumerWhichThrows execute 67 | ) { 68 | 69 | System.out.printf(Locale.US, " %-25s ", message); 70 | 71 | double[][] vals = new double[inputs.length][10]; 72 | double[] avgs = new double[inputs.length]; 73 | for (int j = 0; j < 20000; j++) { 74 | 75 | int mod = j % 100; 76 | 77 | double[] durations = new double[inputs.length]; 78 | boolean allSigmasAreSmall = true; 79 | for (int k = 0; k < inputs.length; k++) { 80 | 81 | final T2 transformedInput = prepare.transform(inputs[k]); 82 | 83 | // durations[i] = probe(new Runnable() { 84 | // @Override public void run() { execute.consume(transformedInput); } 85 | // }); 86 | // Resolution of "System.nanoTime()": approx. 302 ns 87 | { 88 | long start = System.nanoTime(); 89 | for (int i = 0; i < REP2; i++) execute.consume(transformedInput); 90 | long end = System.nanoTime(); 91 | 92 | durations[k] = 1E-9 * (end - start) / REP2; 93 | } 94 | 95 | if (mod < vals[k].length) { 96 | vals[k][mod] = durations[k]; 97 | // System.out.printf(Locale.US, "%d %5d: %,9.3f ns%n", k, j, 1E9 * vals[k][mod]); 98 | } 99 | 100 | if (mod == vals[k].length && j >= 500) { 101 | 102 | Arrays.sort(vals[k]); 103 | double[] vals2 = Arrays.copyOf(vals[k], vals[k].length / 2); 104 | 105 | double sum = 0; 106 | for (int i = 0; i < vals2.length; i++) sum += vals2[i]; 107 | 108 | avgs[k] = sum / vals2.length; 109 | 110 | double sigma; 111 | { 112 | double tmp = 0; 113 | for (int i = 0; i < vals2.length; i++) tmp += sq(vals2[i] - avgs[k]); 114 | sigma = Math.sqrt(tmp) / vals2.length / avgs[k]; 115 | } 116 | 117 | if (sigma > 0.005) allSigmasAreSmall = false; 118 | } else { 119 | allSigmasAreSmall = false; 120 | } 121 | } 122 | 123 | if (allSigmasAreSmall) break; 124 | } 125 | 126 | System.out.printf(Locale.US, "%,7.1f ns ", 1E9 * avgs[0]); 127 | for (int k = 1; k < avgs.length; k++) { 128 | System.out.printf(Locale.US, "%,7.1f ns %5.0f%% ", 1E9 * avgs[k], 100 * avgs[k] / avgs[0]); 129 | } 130 | System.out.printf("%n"); 131 | } 132 | 133 | private static double 134 | sq(double x) { return x * x; } 135 | } 136 | -------------------------------------------------------------------------------- /lfr-core/src/test/java/test/Sampler.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package test; 28 | 29 | import java.lang.Thread.State; 30 | import java.lang.management.ManagementFactory; 31 | import java.lang.management.ThreadInfo; 32 | import java.lang.management.ThreadMXBean; 33 | import java.util.HashMap; 34 | import java.util.Map; 35 | import java.util.concurrent.Executors; 36 | import java.util.concurrent.ScheduledExecutorService; 37 | import java.util.concurrent.TimeUnit; 38 | 39 | import de.unkrig.commons.nullanalysis.NotNullByDefault; 40 | 41 | /** 42 | * Taken from the "Sampler" class. 43 | */ 44 | @NotNullByDefault(false) public final 45 | class Sampler { 46 | 47 | private Sampler() {} 48 | 49 | private static final ThreadMXBean THREAD_MX_BEAN = ManagementFactory.getThreadMXBean(); 50 | 51 | private static String className, methodName; 52 | private static CallTree root; 53 | private static ScheduledExecutorService executor; 54 | 55 | public static synchronized void 56 | startSampling(String className, String methodName) { 57 | 58 | if (Sampler.executor != null) throw new IllegalStateException("sampling in progress"); 59 | 60 | System.out.println("sampling started"); 61 | Sampler.className = className; 62 | Sampler.methodName = methodName; 63 | 64 | Sampler.executor = Executors.newScheduledThreadPool(1); 65 | 66 | // "fixed delay" reduces overhead, "fixed rate" raises precision 67 | Sampler.executor.scheduleWithFixedDelay(new Runnable() { 68 | 69 | @Override public void 70 | run() { Sampler.newSample(); } 71 | }, 5/*150*/, 10/*75*/, TimeUnit.MILLISECONDS); 72 | } 73 | 74 | public static synchronized CallTree 75 | stopSampling() throws InterruptedException { 76 | 77 | if (Sampler.executor == null) throw new IllegalStateException("no sampling in progress"); 78 | 79 | Sampler.executor.shutdown(); 80 | Sampler.executor.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); 81 | Sampler.executor = null; 82 | 83 | final CallTree result = Sampler.root; 84 | Sampler.root = null; 85 | return result; 86 | } 87 | 88 | public static void 89 | printCallTree(CallTree t) { 90 | if (t == null) { 91 | System.out.println("method not seen"); 92 | } else { 93 | Sampler.printCallTree(t, "", 100); 94 | } 95 | } 96 | 97 | private static void 98 | printCallTree(CallTree t, String indent, long percent) { 99 | 100 | long num = 0; 101 | for (CallTree ch : t.values()) num += ch.count; 102 | if (num == 0) return; 103 | 104 | for (Map.Entry e : t.entrySet()) { 105 | String key = e.getKey(); 106 | CallTree subtree = e.getValue(); 107 | 108 | System.out.println( 109 | indent 110 | + (subtree.count * percent / num) 111 | + "% (" 112 | + (subtree.cpu * percent / num) 113 | + "% cpu) " 114 | + key 115 | ); 116 | 117 | Sampler.printCallTree(subtree, indent + " ", subtree.count * percent / num); 118 | } 119 | } 120 | 121 | static 122 | class CallTree extends HashMap { 123 | 124 | private static final long serialVersionUID = 1L; 125 | 126 | long count = 1, cpu; 127 | 128 | CallTree(boolean cpu) { if (cpu) this.cpu++; } 129 | 130 | CallTree 131 | getOrAdd(StackTraceElement ste, boolean cpu) { 132 | 133 | String key = ste.getClassName() + '.' + ste.getMethodName() + "():" + ste.getLineNumber(); 134 | 135 | CallTree t = this.get(key); 136 | if (t != null) { 137 | t.count++; 138 | if (cpu) t.cpu++; 139 | } else { 140 | this.put(key, (t = new CallTree(cpu))); 141 | } 142 | 143 | return t; 144 | } 145 | } 146 | 147 | static void 148 | newSample() { 149 | 150 | for (ThreadInfo ti : Sampler.THREAD_MX_BEAN.dumpAllThreads(false, false)) { 151 | 152 | final boolean cpu = ti.getThreadState() == State.RUNNABLE; 153 | 154 | StackTraceElement[] stack = ti.getStackTrace(); 155 | 156 | int ix; 157 | for (ix = stack.length - 1; ix >= 0; ix--) { 158 | StackTraceElement ste = stack[ix]; 159 | 160 | if (ste.getClassName().equals(Sampler.className) && ste.getMethodName().equals(Sampler.methodName)) { 161 | break; 162 | } 163 | } 164 | 165 | CallTree t = Sampler.root; 166 | if (t == null) Sampler.root = (t = new CallTree(cpu)); 167 | 168 | for (ix--; ix >= 0; ix--) { 169 | StackTraceElement ste = stack[ix]; 170 | t = t.getOrAdd(ste, cpu); 171 | } 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /lfr-core/src/test/java/test/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * de.unkrig.lfr - A super-fast regular expression evaluator 4 | * 5 | * Copyright (c) 2016, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | /** 28 | * A super-fast drop-in replacement for {@code java.util.regex}. 29 | */ 30 | @NotNullByDefault 31 | package test; 32 | 33 | import de.unkrig.commons.nullanalysis.NotNullByDefault; 34 | -------------------------------------------------------------------------------- /lfr-parent/.keep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lfr-parent/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | lfr-parent 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /lfr-parent/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /lfr-parent/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /lfr-parent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | de.unkrig.lfr 5 | lfr-parent 6 | 1.2.1-SNAPSHOT 7 | 8 | pom 9 | 10 | Parent project for the LFR modules 11 | https://github.com/aunkrig/lfr/ 12 | de.unkrig.lfr - A 99.9% compatible reimplementation of java.util.regex with better performance 13 | 14 | 15 | Arno Unkrig 16 | http://unkrig.de/ 17 | 18 | 19 | 20 | https://github.com/aunkrig/lfr 21 | 22 | 23 | 24 | 25 | Arno Unkrig 26 | arno@unkrig.de 27 | 28 | 29 | 30 | 31 | 32 | New BSD License 33 | http://unkrig.de/w/New_BSD_License 34 | 35 | 36 | 37 | 38 | 1.8 39 | 1.8 40 | UTF-8 41 | 42 | 1.2.18-SNAPSHOT 43 | 4.13.1 44 | 45 | 46 | 47 | 48 | ossrh 49 | https://oss.sonatype.org/content/repositories/snapshots 50 | 51 | 52 | 53 | 54 | 55 | 56 | de.unkrig.commons 57 | commons-text 58 | ${de.unkrig.commons-version} 59 | 60 | 61 | de.unkrig.commons 62 | commons-util 63 | ${de.unkrig.commons-version} 64 | 65 | 66 | junit 67 | junit 68 | ${junit-version} 69 | test 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | org.sonatype.plugins 78 | nexus-staging-maven-plugin 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | org.apache.maven.plugins 88 | maven-jar-plugin 89 | 2.4 90 | 91 | 92 | test-jar 93 | 94 | 95 | 96 | 97 | 98 | 99 | org.apache.maven.plugins 100 | maven-gpg-plugin 101 | 1.5 102 | 103 | 104 | sign-artifacts 105 | verify 106 | sign 107 | 108 | 109 | 110 | 111 | 112 | 113 | org.apache.maven.plugins 114 | maven-source-plugin 115 | 2.4 116 | 117 | 118 | attach-sources 119 | jar 120 | 121 | 122 | 123 | 124 | 125 | 126 | org.sonatype.plugins 127 | nexus-staging-maven-plugin 128 | 1.6.7 129 | true 130 | 131 | ossrh 132 | https://oss.sonatype.org/ 133 | false 134 | 135 | 136 | 137 | 138 | 139 | org.apache.maven.plugins 140 | maven-javadoc-plugin 141 | 2.10.4 142 | 143 | 144 | attach-javadocs 145 | jar 146 | 147 | 148 | 149 | 150 | false 151 | false 152 | false 153 | -Xdoclint:none 154 | UTF-8 155 | true 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | have_gpg 167 | 168 | 169 | 170 | org.apache.maven.plugins 171 | maven-gpg-plugin 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | ../lfr-core 180 | ../openjdk8_regex_tests 181 | ../openjdk15_regex_tests 182 | ../ref4j 183 | 184 | 185 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/.keep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | openjdk15_regex_tests 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.8 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 12 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 13 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 14 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 15 | org.eclipse.jdt.core.compiler.release=disabled 16 | org.eclipse.jdt.core.compiler.source=1.8 17 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/launch/openjdk15_regex_tests (JRE 11).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/launch/openjdk15_regex_tests (JRE 17).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/launch/openjdk15_regex_tests (JRE 8).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | openjdk15_regex_tests 5 | 6 | OpenJDK 15 regex test suite 7 | http://hg.openjdk.java.net/jdk/jdk15/file/0dabbdfd97e6/test/jdk/java/util/regex 8 | 9 | 10 | 11 | 8 12 | 8 13 | 14 | 15 | 16 | 17 | 18 | junit 19 | junit 20 | test 21 | 22 | 23 | de.unkrig.lfr 24 | lfr-core 25 | ${project.parent.version} 26 | jar 27 | test 28 | 29 | 30 | de.unkrig.lfr 31 | lfr-core 32 | ${project.parent.version} 33 | test-jar 34 | test 35 | 36 | 37 | 38 | 39 | de.unkrig.lfr 40 | lfr-parent 41 | 1.2.1-SNAPSHOT 42 | ../lfr-parent 43 | 44 | 45 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/src/main/java/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/openjdk15_regex_tests/src/main/java/.keep -------------------------------------------------------------------------------- /openjdk15_regex_tests/src/main/resources/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/openjdk15_regex_tests/src/main/resources/.keep -------------------------------------------------------------------------------- /openjdk15_regex_tests/src/test/java/NegativeArraySize.java.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 | * or visit www.oracle.com if you need additional information or have any 21 | * questions. 22 | */ 23 | 24 | /* 25 | * @test 26 | * @bug 8223174 27 | * @summary Pattern.compile() can throw confusing NegativeArraySizeException 28 | * @requires os.maxMemory >= 5g 29 | * @run main/othervm NegativeArraySize -Xms5G -Xmx5G 30 | */ 31 | 32 | import java.util.regex.Pattern; 33 | 34 | public class NegativeArraySize { 35 | public static void main(String[] args) { 36 | try { 37 | Pattern.compile("\\Q" + "a".repeat(42 + Integer.MAX_VALUE / 3)); 38 | throw new AssertionError("expected to throw"); 39 | } catch (OutOfMemoryError expected) { 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/src/test/java/POSIX_Unicode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 | * or visit www.oracle.com if you need additional information or have any 21 | * questions. 22 | */ 23 | 24 | public final class POSIX_Unicode { 25 | 26 | public static boolean isAlpha(int ch) { 27 | return Character.isAlphabetic(ch); 28 | } 29 | 30 | public static boolean isLower(int ch) { 31 | return Character.isLowerCase(ch); 32 | } 33 | 34 | public static boolean isUpper(int ch) { 35 | return Character.isUpperCase(ch); 36 | } 37 | 38 | // \p{Whitespace} 39 | public static boolean isSpace(int ch) { 40 | return ((((1 << Character.SPACE_SEPARATOR) | 41 | (1 << Character.LINE_SEPARATOR) | 42 | (1 << Character.PARAGRAPH_SEPARATOR)) >> Character.getType(ch)) & 1) 43 | != 0 || 44 | (ch >= 0x9 && ch <= 0xd) || 45 | (ch == 0x85); 46 | } 47 | 48 | // \p{gc=Control} 49 | public static boolean isCntrl(int ch) { 50 | return Character.getType(ch) == Character.CONTROL; 51 | } 52 | 53 | // \p{gc=Punctuation} 54 | public static boolean isPunct(int ch) { 55 | return ((((1 << Character.CONNECTOR_PUNCTUATION) | 56 | (1 << Character.DASH_PUNCTUATION) | 57 | (1 << Character.START_PUNCTUATION) | 58 | (1 << Character.END_PUNCTUATION) | 59 | (1 << Character.OTHER_PUNCTUATION) | 60 | (1 << Character.INITIAL_QUOTE_PUNCTUATION) | 61 | (1 << Character.FINAL_QUOTE_PUNCTUATION)) >> Character.getType(ch)) & 1) 62 | != 0; 63 | } 64 | 65 | // \p{gc=Decimal_Number} 66 | // \p{Hex_Digit} -> PropList.txt: Hex_Digit 67 | public static boolean isHexDigit(int ch) { 68 | return Character.isDigit(ch) || 69 | (ch >= 0x0030 && ch <= 0x0039) || 70 | (ch >= 0x0041 && ch <= 0x0046) || 71 | (ch >= 0x0061 && ch <= 0x0066) || 72 | (ch >= 0xFF10 && ch <= 0xFF19) || 73 | (ch >= 0xFF21 && ch <= 0xFF26) || 74 | (ch >= 0xFF41 && ch <= 0xFF46); 75 | } 76 | 77 | // \p{gc=Decimal_Number} 78 | public static boolean isDigit(int ch) { 79 | return Character.isDigit(ch); 80 | }; 81 | 82 | // \p{alpha} 83 | // \p{digit} 84 | public static boolean isAlnum(int ch) { 85 | return Character.isAlphabetic(ch) || Character.isDigit(ch); 86 | } 87 | 88 | // \p{Whitespace} -- 89 | // [\N{LF} \N{VT} \N{FF} \N{CR} \N{NEL} -> 0xa, 0xb, 0xc, 0xd, 0x85 90 | // \p{gc=Line_Separator} 91 | // \p{gc=Paragraph_Separator}] 92 | public static boolean isBlank(int ch) { 93 | int type = Character.getType(ch); 94 | return isSpace(ch) && 95 | ch != 0xa & ch != 0xb && ch !=0xc && ch != 0xd && ch != 0x85 && 96 | type != Character.LINE_SEPARATOR && 97 | type != Character.PARAGRAPH_SEPARATOR; 98 | } 99 | 100 | // [^ 101 | // \p{space} 102 | // \p{gc=Control} 103 | // \p{gc=Surrogate} 104 | // \p{gc=Unassigned}] 105 | public static boolean isGraph(int ch) { 106 | int type = Character.getType(ch); 107 | return !(isSpace(ch) || 108 | Character.CONTROL == type || 109 | Character.SURROGATE == type || 110 | Character.UNASSIGNED == type); 111 | } 112 | 113 | // \p{graph} 114 | // \p{blank} 115 | // -- \p{cntrl} 116 | public static boolean isPrint(int ch) { 117 | return (isGraph(ch) || isBlank(ch)) && !isCntrl(ch); 118 | } 119 | 120 | // PropList.txt:Noncharacter_Code_Point 121 | public static boolean isNoncharacterCodePoint(int ch) { 122 | return (ch & 0xfffe) == 0xfffe || (ch >= 0xfdd0 && ch <= 0xfdef); 123 | } 124 | 125 | public static boolean isJoinControl(int ch) { 126 | return (ch == 0x200C || ch == 0x200D); 127 | } 128 | 129 | // \p{alpha} 130 | // \p{gc=Mark} 131 | // \p{digit} 132 | // \p{gc=Connector_Punctuation} 133 | public static boolean isWord(int ch) { 134 | return isAlpha(ch) || 135 | ((((1 << Character.NON_SPACING_MARK) | 136 | (1 << Character.ENCLOSING_MARK) | 137 | (1 << Character.COMBINING_SPACING_MARK) | 138 | (1 << Character.CONNECTOR_PUNCTUATION)) >> Character.getType(ch)) & 1) 139 | != 0 || 140 | isDigit(ch) || 141 | isJoinControl(ch); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /openjdk15_regex_tests/src/test/resources/GraphemeTestCases.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | # 5 | # This code is free software; you can redistribute it and/or modify it 6 | # under the terms of the GNU General Public License version 2 only, as 7 | # published by the Free Software Foundation. 8 | # 9 | # This code is distributed in the hope that it will be useful, but WITHOUT 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | # version 2 for more details (a copy is included in the LICENSE file that 13 | # accompanied this code). 14 | # 15 | # You should have received a copy of the GNU General Public License version 16 | # 2 along with this work; if not, write to the Free Software Foundation, 17 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | # 19 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 | # or visit www.oracle.com if you need additional information or have any 21 | # questions. 22 | # 23 | 24 | # test cases for Grapheme support. Format follows GrahemeBreakTest.txt 25 | # from Unicode. 26 | # https://unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.html 27 | 28 | # bug 8216332 29 | ÷ 1F468 × 1F3FE ÷ 1F468 × 200D × 1F469 × 200D × 1F466 ÷ 30 | ÷ 1F468 × 200D × 1F469 × 200D × 1F466 × 200d ÷ 0041 ÷ 31 | ÷ 1F468 × 200D × 1F469 × 200D × 1F466 ÷ 0041 ÷ 32 | ÷ 0041 ÷ 1F468 × 200D × 1F469 × 200D × 1F466 ÷ 0041 ÷ 33 | ÷ 1F468 × 200D × 1F3FE × 200D × 1F469 × 1F3FE × 200D × 1F466 ÷ 0041 ÷ 34 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | openjdk8_regex_tests 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 10 | org.eclipse.jdt.core.compiler.release=disabled 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/README.md: -------------------------------------------------------------------------------- 1 | These three source files originate from 2 | 3 | http://hg.openjdk.java.net/jdk8u/jdk8u60/jdk/file/935758609767/test/java/util/regex 4 | 5 | and implement the ultimate notion of JRE regex compatibility. 6 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/launch/openjdk8_regex_tests (JRE 11).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/launch/openjdk8_regex_tests (JRE 17).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/launch/openjdk8_regex_tests (JRE 8).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | openjdk8_regex_tests 5 | 6 | OpenJDK 8 regex test suite 7 | http://hg.openjdk.java.net/jdk8u/jdk8u60/jdk/file/935758609767/test/java/util/regex 8 | 9 | 10 | 11 | junit 12 | junit 13 | test 14 | 15 | 16 | de.unkrig.lfr 17 | lfr-core 18 | ${project.parent.version} 19 | jar 20 | test 21 | 22 | 23 | de.unkrig.lfr 24 | lfr-core 25 | ${project.parent.version} 26 | test-jar 27 | test 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | have_gpg 36 | 37 | 38 | 39 | org.apache.maven.plugins 40 | maven-gpg-plugin 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | de.unkrig.lfr 49 | lfr-parent 50 | 1.2.1-SNAPSHOT 51 | ../lfr-parent 52 | 53 | -------------------------------------------------------------------------------- /openjdk8_regex_tests/src/main/java/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/openjdk8_regex_tests/src/main/java/.empty -------------------------------------------------------------------------------- /openjdk8_regex_tests/src/main/resources/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aunkrig/lfr/23307329ef2e2d9469e715067e7ce39d2c313b3f/openjdk8_regex_tests/src/main/resources/.empty -------------------------------------------------------------------------------- /openjdk8_regex_tests/src/test/java/POSIX_Unicode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 | * or visit www.oracle.com if you need additional information or have any 21 | * questions. 22 | */ 23 | 24 | final public class POSIX_Unicode { 25 | 26 | public static boolean isAlpha(int ch) { 27 | return Character.isAlphabetic(ch); 28 | } 29 | 30 | public static boolean isLower(int ch) { 31 | return Character.isLowerCase(ch); 32 | } 33 | 34 | public static boolean isUpper(int ch) { 35 | return Character.isUpperCase(ch); 36 | } 37 | 38 | // \p{Whitespace} 39 | public static boolean isSpace(int ch) { 40 | return ((((1 << Character.SPACE_SEPARATOR) | 41 | (1 << Character.LINE_SEPARATOR) | 42 | (1 << Character.PARAGRAPH_SEPARATOR)) >> Character.getType(ch)) & 1) 43 | != 0 || 44 | (ch >= 0x9 && ch <= 0xd) || 45 | (ch == 0x85); 46 | } 47 | 48 | // \p{gc=Control} 49 | public static boolean isCntrl(int ch) { 50 | return Character.getType(ch) == Character.CONTROL; 51 | } 52 | 53 | // \p{gc=Punctuation} 54 | public static boolean isPunct(int ch) { 55 | return ((((1 << Character.CONNECTOR_PUNCTUATION) | 56 | (1 << Character.DASH_PUNCTUATION) | 57 | (1 << Character.START_PUNCTUATION) | 58 | (1 << Character.END_PUNCTUATION) | 59 | (1 << Character.OTHER_PUNCTUATION) | 60 | (1 << Character.INITIAL_QUOTE_PUNCTUATION) | 61 | (1 << Character.FINAL_QUOTE_PUNCTUATION)) >> Character.getType(ch)) & 1) 62 | != 0; 63 | } 64 | 65 | // \p{gc=Decimal_Number} 66 | // \p{Hex_Digit} -> PropList.txt: Hex_Digit 67 | public static boolean isHexDigit(int ch) { 68 | return Character.isDigit(ch) || 69 | (ch >= 0x0030 && ch <= 0x0039) || 70 | (ch >= 0x0041 && ch <= 0x0046) || 71 | (ch >= 0x0061 && ch <= 0x0066) || 72 | (ch >= 0xFF10 && ch <= 0xFF19) || 73 | (ch >= 0xFF21 && ch <= 0xFF26) || 74 | (ch >= 0xFF41 && ch <= 0xFF46); 75 | } 76 | 77 | // \p{gc=Decimal_Number} 78 | public static boolean isDigit(int ch) { 79 | return Character.isDigit(ch); 80 | }; 81 | 82 | // \p{alpha} 83 | // \p{digit} 84 | public static boolean isAlnum(int ch) { 85 | return Character.isAlphabetic(ch) || Character.isDigit(ch); 86 | } 87 | 88 | // \p{Whitespace} -- 89 | // [\N{LF} \N{VT} \N{FF} \N{CR} \N{NEL} -> 0xa, 0xb, 0xc, 0xd, 0x85 90 | // \p{gc=Line_Separator} 91 | // \p{gc=Paragraph_Separator}] 92 | public static boolean isBlank(int ch) { 93 | int type = Character.getType(ch); 94 | return POSIX_Unicode.isSpace(ch) && 95 | ch != 0xa & ch != 0xb && ch !=0xc && ch != 0xd && ch != 0x85 && 96 | type != Character.LINE_SEPARATOR && 97 | type != Character.PARAGRAPH_SEPARATOR; 98 | } 99 | 100 | // [^ 101 | // \p{space} 102 | // \p{gc=Control} 103 | // \p{gc=Surrogate} 104 | // \p{gc=Unassigned}] 105 | public static boolean isGraph(int ch) { 106 | int type = Character.getType(ch); 107 | return !(POSIX_Unicode.isSpace(ch) || 108 | Character.CONTROL == type || 109 | Character.SURROGATE == type || 110 | Character.UNASSIGNED == type); 111 | } 112 | 113 | // \p{graph} 114 | // \p{blank} 115 | // -- \p{cntrl} 116 | public static boolean isPrint(int ch) { 117 | return (POSIX_Unicode.isGraph(ch) || POSIX_Unicode.isBlank(ch)) && !POSIX_Unicode.isCntrl(ch); 118 | } 119 | 120 | // PropList.txt:Noncharacter_Code_Point 121 | public static boolean isNoncharacterCodePoint(int ch) { 122 | return (ch & 0xfffe) == 0xfffe || (ch >= 0xfdd0 && ch <= 0xfdef); 123 | } 124 | 125 | public static boolean isJoinControl(int ch) { 126 | return (ch == 0x200C || ch == 0x200D); 127 | } 128 | 129 | // \p{alpha} 130 | // \p{gc=Mark} 131 | // \p{digit} 132 | // \p{gc=Connector_Punctuation} 133 | public static boolean isWord(int ch) { 134 | return POSIX_Unicode.isAlpha(ch) || 135 | ((((1 << Character.NON_SPACING_MARK) | 136 | (1 << Character.ENCLOSING_MARK) | 137 | (1 << Character.COMBINING_SPACING_MARK) | 138 | (1 << Character.CONNECTOR_PUNCTUATION)) >> Character.getType(ch)) & 1) 139 | != 0 || 140 | POSIX_Unicode.isDigit(ch) || 141 | POSIX_Unicode.isJoinControl(ch); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /ref4j/.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ref4j/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ref4j/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /ref4j/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ref4j 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | net.sf.eclipsecs.core.CheckstyleBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | net.sf.eclipsecs.core.CheckstyleNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /ref4j/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /ref4j/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 10 | org.eclipse.jdt.core.compiler.release=disabled 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /ref4j/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /ref4j/foo.txt: -------------------------------------------------------------------------------- 1 | cc 2 | -------------------------------------------------------------------------------- /ref4j/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | ref4j 5 | 6 | Regular Expression Facade for Java 7 | A facade or abstraction for various regular expression frameworks (currently java.util.regex and de.unkrig.lfr). 8 | 9 | 10 | 11 | de.unkrig.commons 12 | commons-util 13 | 14 | 15 | junit 16 | junit 17 | test 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-jar-plugin 26 | 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-source-plugin 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-javadoc-plugin 36 | 37 | 38 | 39 | org.sonatype.plugins 40 | nexus-staging-maven-plugin 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | have_gpg 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-gpg-plugin 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | de.unkrig.lfr 63 | lfr-parent 64 | 1.2.1-SNAPSHOT 65 | ../lfr-parent 66 | 67 | -------------------------------------------------------------------------------- /ref4j/src/main/java/de/unkrig/ref4j/PatternFactory.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * ref4j - Regular Expression Facade for Java 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package de.unkrig.ref4j; 28 | 29 | import java.util.Iterator; 30 | import java.util.regex.PatternSyntaxException; 31 | 32 | import de.unkrig.commons.nullanalysis.NotNullByDefault; 33 | import de.unkrig.commons.nullanalysis.Nullable; 34 | import de.unkrig.commons.util.EnhancedServiceLoader; 35 | 36 | /** 37 | * A facade or abstraction for various regular expression frameworks. 38 | *

39 | * To get 40 | *

41 | *
 42 |  * {@code ServiceLoader patternFactory = ServiceLoader.load(PatternFactory.class);}
 43 |  * 
44 | */ 45 | @NotNullByDefault public abstract 46 | class PatternFactory { 47 | 48 | /** 49 | * Returns the pattern factory configured in this JVM. 50 | *
    51 | *
  • 52 | * The class named by the system property "de.unkrig.ref4j.PatternFactory" (if the system property is set 53 | * and the class is registered as a pattern factory) 54 | *
  • 55 | *
  • 56 | * The first of all registered pattern factories on the classpath (if any) 57 | *
  • 58 | *
  • 59 | * The {@code java.util.regex} pattern factory 60 | *
  • 61 | *
62 | * 63 | * @see EnhancedServiceLoader#load(Class) 64 | */ 65 | public static PatternFactory 66 | get() { 67 | 68 | String patternFactoryClassName = System.getProperty("de.unkrig.ref4j.PatternFactory"); 69 | if (patternFactoryClassName != null) return PatternFactory.get(patternFactoryClassName); 70 | 71 | Iterator it = EnhancedServiceLoader.DEFAULT.load(PatternFactory.class).iterator(); 72 | 73 | return it.hasNext() ? it.next() : de.unkrig.ref4j.jur.PatternFactory.INSTANCE; 74 | } 75 | 76 | /** 77 | * @return A package name-like string that is unique among all existing pattern factory implementations 78 | */ 79 | public abstract String 80 | getId(); 81 | 82 | /** 83 | * @return The class that has the given name and extends the {@link PatternFactory} class 84 | */ 85 | @Nullable public static PatternFactory 86 | get(String fullyQualifiedClassName) { 87 | 88 | for (PatternFactory pf : EnhancedServiceLoader.DEFAULT.load(PatternFactory.class)) { 89 | if (pf.getClass().getName().equals(fullyQualifiedClassName)) return pf; 90 | } 91 | 92 | return null; 93 | } 94 | 95 | /** 96 | * @return The union of all flags supported by {@code this} engine. 97 | */ 98 | public abstract int 99 | getSupportedFlags(); 100 | 101 | /** 102 | * Compiles the given regex into a {@link Pattern}. 103 | */ 104 | public Pattern 105 | compile(String regex) throws PatternSyntaxException { return this.compile(regex, 0); } 106 | 107 | /** 108 | * Compiles the given regex into a {@link Pattern} with the given flags. 109 | * 110 | * @param flags The or'ed compilation flag constants declared by {@link Pattern} 111 | * @throws IllegalArgumentException A flag was given that is not set in {@link #getSupportedFlags()} 112 | * @see java.util.regex.Pattern#compile(String, int) 113 | * @see java.util.regex.Pattern#compile(String) 114 | * @see Pattern#CANON_EQ 115 | * @see Pattern#CASE_INSENSITIVE 116 | * @see Pattern#COMMENTS 117 | * @see Pattern#DOTALL 118 | * @see Pattern#LITERAL 119 | * @see Pattern#MULTILINE 120 | * @see Pattern#UNICODE_CASE 121 | * @see Pattern#UNICODE_CHARACTER_CLASS 122 | * @see Pattern#UNIX_LINES 123 | */ 124 | public abstract Pattern 125 | compile(String regex, int flags) throws PatternSyntaxException; 126 | 127 | /** 128 | * @see java.util.regex.Pattern#matches(String, CharSequence) 129 | */ 130 | public abstract boolean 131 | matches(String regex, CharSequence input); 132 | 133 | /** 134 | * @see java.util.regex.Pattern#quote(String) 135 | */ 136 | public String 137 | quote(String s) { return java.util.regex.Pattern.quote(s); } 138 | 139 | /** 140 | * @see java.util.regex.Matcher#quoteReplacement(String) 141 | */ 142 | public String 143 | quoteReplacement(String s) { return java.util.regex.Matcher.quoteReplacement(s); } 144 | } 145 | -------------------------------------------------------------------------------- /ref4j/src/main/java/de/unkrig/ref4j/jur/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * ref4j - Regular Expression Facade for Java 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | @NotNullByDefault 28 | package de.unkrig.ref4j.jur; 29 | 30 | import de.unkrig.commons.nullanalysis.NotNullByDefault; 31 | -------------------------------------------------------------------------------- /ref4j/src/main/java/de/unkrig/ref4j/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * ref4j - Regular Expression Facade for Java 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | @NotNullByDefault 28 | package de.unkrig.ref4j; 29 | 30 | import de.unkrig.commons.nullanalysis.NotNullByDefault; 31 | -------------------------------------------------------------------------------- /ref4j/src/main/resources/META-INF/services/de.unkrig.ref4j.PatternFactory: -------------------------------------------------------------------------------- 1 | 2 | # The "java.util.regex" implementation of de.unkrig.ref4j.PatternFactory: 3 | de.unkrig.ref4j.jur.PatternFactory 4 | de.unkrig.ref4j.jur.PatternFactory.instanceField = INSTANCE 5 | -------------------------------------------------------------------------------- /ref4j/src/test/java/ref4j/Ref4JTests.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * ref4j - Regular Expression Facade for Java 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | package ref4j; 28 | 29 | import java.io.IOException; 30 | 31 | import org.junit.Test; 32 | 33 | import de.unkrig.ref4j.PatternFactory; 34 | 35 | public 36 | class Ref4JTests { 37 | 38 | @Test public void 39 | testFactory() throws IOException { 40 | @SuppressWarnings("unused") PatternFactory pf = PatternFactory.get(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ref4j/src/test/java/ref4j/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * ref4j - Regular Expression Facade for Java 4 | * 5 | * Copyright (c) 2017, Arno Unkrig 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 9 | * following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 14 | * following disclaimer in the documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 16 | * products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | @NotNullByDefault 28 | package ref4j; 29 | 30 | import de.unkrig.commons.nullanalysis.NotNullByDefault; 31 | --------------------------------------------------------------------------------