Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Trino RE2J fork to a new package #4

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/syntax/parse.go

package com.google.re2j;
package io.trino.re2j;

/**
* A "builder"-style helper class for manipulating character classes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// GENERATED BY make_perl_groups.pl; DO NOT EDIT.
// make_perl_groups.pl >perl_groups.go

package com.google.re2j;
package io.trino.re2j;

import java.util.HashMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/syntax/compile.go

package com.google.re2j;
package io.trino.re2j;

import java.util.LinkedList;
import java.util.List;

import static com.google.re2j.Inst.Op.BYTE;
import static com.google.re2j.Inst.Op.BYTE1;
import static com.google.re2j.RE2.FOLD_CASE;
import static com.google.re2j.Unicode.RUNE_SELF;
import static com.google.re2j.Unicode.UTF_MAX;
import static com.google.re2j.Unicode.codePointToUtf8;
import static com.google.re2j.Unicode.maxRune;
import static com.google.re2j.Unicode.simpleFold;
import static io.trino.re2j.Inst.Op.BYTE;
import static io.trino.re2j.Inst.Op.BYTE1;
import static io.trino.re2j.RE2.FOLD_CASE;
import static io.trino.re2j.Unicode.RUNE_SELF;
import static io.trino.re2j.Unicode.UTF_MAX;
import static io.trino.re2j.Unicode.codePointToUtf8;
import static io.trino.re2j.Unicode.maxRune;
import static io.trino.re2j.Unicode.simpleFold;

/**
* Compiler from {@code Regexp} (RE2 abstract syntax) to {@code RE2} (compiled regular expression).
Expand Down
30 changes: 15 additions & 15 deletions java/com/google/re2j/DFA.java → java/io/trino/re2j/DFA.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
// Original RE2 source here:
// https://github.com/google/re2/blob/master/re2/dfa.cc

package com.google.re2j;
package io.trino.re2j;

import com.google.re2j.RE2.MatchKind;
import io.trino.re2j.RE2.MatchKind;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import static com.google.re2j.DFAState.DEAD_STATE;
import static com.google.re2j.Inst.Op.EMPTY_WIDTH;
import static com.google.re2j.MachineInput.EOF;
import static com.google.re2j.RE2.MatchKind.FIRST_MATCH;
import static com.google.re2j.RE2.MatchKind.LONGEST_MATCH;
import static com.google.re2j.Utils.EMPTY_BEGIN_LINE;
import static com.google.re2j.Utils.EMPTY_BEGIN_TEXT;
import static com.google.re2j.Utils.EMPTY_END_LINE;
import static com.google.re2j.Utils.EMPTY_END_TEXT;
import static com.google.re2j.Utils.EMPTY_NO_WORD_BOUNDARY;
import static com.google.re2j.Utils.EMPTY_WORD_BOUNDARY;
import static com.google.re2j.Utils.isRuneStart;
import static com.google.re2j.Utils.isWordByte;
import static io.trino.re2j.DFAState.DEAD_STATE;
import static io.trino.re2j.Inst.Op.EMPTY_WIDTH;
import static io.trino.re2j.MachineInput.EOF;
import static io.trino.re2j.RE2.MatchKind.FIRST_MATCH;
import static io.trino.re2j.RE2.MatchKind.LONGEST_MATCH;
import static io.trino.re2j.Utils.EMPTY_BEGIN_LINE;
import static io.trino.re2j.Utils.EMPTY_BEGIN_TEXT;
import static io.trino.re2j.Utils.EMPTY_END_LINE;
import static io.trino.re2j.Utils.EMPTY_END_TEXT;
import static io.trino.re2j.Utils.EMPTY_NO_WORD_BOUNDARY;
import static io.trino.re2j.Utils.EMPTY_WORD_BOUNDARY;
import static io.trino.re2j.Utils.isRuneStart;
import static io.trino.re2j.Utils.isWordByte;
import static java.util.Arrays.sort;

class DFA {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
// Original RE2 source here:
// https://github.com/google/re2/blob/master/re2/dfa.cc

package com.google.re2j;
package io.trino.re2j;

import com.google.re2j.RE2.Anchor;
import com.google.re2j.RE2.MatchKind;
import io.trino.re2j.RE2.Anchor;
import io.trino.re2j.RE2.MatchKind;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import static com.google.re2j.DFA.NO_MATCH;
import static com.google.re2j.RE2.Anchor.ANCHOR_START;
import static com.google.re2j.RE2.MatchKind.FIRST_MATCH;
import static com.google.re2j.RE2.MatchKind.LONGEST_MATCH;
import static io.trino.re2j.DFA.NO_MATCH;
import static io.trino.re2j.RE2.Anchor.ANCHOR_START;
import static io.trino.re2j.RE2.MatchKind.FIRST_MATCH;
import static io.trino.re2j.RE2.MatchKind.LONGEST_MATCH;

/**
* A {@link Machine} implementation using a DFA.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Original RE2 source here:
// https://github.com/google/re2/blob/master/re2/dfa.cc

package com.google.re2j;
package io.trino.re2j;

import static com.google.re2j.DFA.FLAG_MATCH;
import static com.google.re2j.DFAState.StateType.DEAD;
import static com.google.re2j.DFAState.StateType.REGULAR;
import static io.trino.re2j.DFA.FLAG_MATCH;
import static io.trino.re2j.DFAState.StateType.DEAD;
import static io.trino.re2j.DFAState.StateType.REGULAR;
import static java.lang.System.arraycopy;

final class DFAState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Original RE2 source here:
// https://github.com/google/re2/blob/master/re2/dfa.cc

package com.google.re2j;
package io.trino.re2j;

import java.util.Arrays;

import static com.google.re2j.Utils.arrayFirstElementsEqual;
import static io.trino.re2j.Utils.arrayFirstElementsEqual;

final class DFAStateKey {
private final int[] instIndexes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/syntax/prog.go

package com.google.re2j;
package io.trino.re2j;

import static com.google.re2j.Inst.Op.BYTE;
import static io.trino.re2j.Inst.Op.BYTE;

/**
* A single instruction in the regular expression virtual machine.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/exec.go

package com.google.re2j;
package io.trino.re2j;

import com.google.re2j.RE2.Anchor;
import io.trino.re2j.RE2.Anchor;

/**
* A Machine matches an input string of Unicode characters against an RE2 instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/regexp.go

package com.google.re2j;
package io.trino.re2j;

import io.airlift.slice.Slice;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright 2010 Google Inc. All Rights Reserved.

package com.google.re2j;

import com.google.re2j.RE2.Anchor;
package io.trino.re2j;

import io.airlift.slice.DynamicSliceOutput;
import io.airlift.slice.Slice;
import io.airlift.slice.SliceOutput;
import io.trino.re2j.RE2.Anchor;

import static com.google.re2j.RE2.Anchor.ANCHOR_BOTH;
import static com.google.re2j.RE2.Anchor.ANCHOR_START;
import static com.google.re2j.RE2.Anchor.UNANCHORED;
import static io.trino.re2j.RE2.Anchor.ANCHOR_BOTH;
import static io.trino.re2j.RE2.Anchor.ANCHOR_START;
import static io.trino.re2j.RE2.Anchor.UNANCHORED;

/**
* A stateful iterator that interprets a regex {@code Pattern} on a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/exec.go

package com.google.re2j;
package io.trino.re2j;

import com.google.re2j.RE2.Anchor;
import io.trino.re2j.RE2.Anchor;

import java.util.Arrays;

import static com.google.re2j.MachineInput.EOF;
import static com.google.re2j.RE2.MatchKind.LONGEST_MATCH;
import static com.google.re2j.Utils.emptyOpContext;
import static com.google.re2j.Utils.isRuneStart;
import static io.trino.re2j.MachineInput.EOF;
import static io.trino.re2j.RE2.MatchKind.LONGEST_MATCH;
import static io.trino.re2j.Utils.emptyOpContext;
import static io.trino.re2j.Utils.isRuneStart;
import static java.lang.System.arraycopy;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package com.google.re2j;
package io.trino.re2j;

import java.io.Serializable;

import static com.google.re2j.Options.Algorithm.DFA;
import static io.trino.re2j.Options.Algorithm.DFA;
import static java.util.Objects.requireNonNull;

public final class Options implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// - Eliminate allocations (new int[], new Regexp[], new ArrayList) by
// recycling old arrays on a freelist.

package com.google.re2j;
package io.trino.re2j;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright 2010 Google Inc. All Rights Reserved.

package com.google.re2j;
package io.trino.re2j;

import java.io.Serializable;

import io.airlift.slice.Slice;

import static com.google.re2j.Options.DEFAULT_OPTIONS;
import static com.google.re2j.RE2.Anchor.ANCHOR_BOTH;
import static com.google.re2j.RE2.Anchor.UNANCHORED;
import static com.google.re2j.RE2.MatchKind.FIRST_MATCH;
import static io.trino.re2j.Options.DEFAULT_OPTIONS;
import static io.trino.re2j.RE2.Anchor.ANCHOR_BOTH;
import static io.trino.re2j.RE2.Anchor.UNANCHORED;
import static io.trino.re2j.RE2.MatchKind.FIRST_MATCH;

/**
* A compiled representation of an RE2 regular expression, mimicking the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package com.google.re2j;
package io.trino.re2j;

/**
* An exception thrown by the parser if the pattern was invalid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/syntax/prog.go

package com.google.re2j;
package io.trino.re2j;

import java.util.ArrayList;
import java.util.List;

import io.airlift.slice.SliceOutput;
import io.airlift.slice.Slices;

import static com.google.re2j.Inst.Op.BYTE;
import static com.google.re2j.Inst.Op.MATCH;
import static io.trino.re2j.Inst.Op.BYTE;
import static io.trino.re2j.Inst.Op.MATCH;

/**
* A Prog is a compiled regular expression program.
Expand Down
16 changes: 8 additions & 8 deletions java/com/google/re2j/RE2.java → java/io/trino/re2j/RE2.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
// the primary input datatype, and the method names have been changed to
// reflect this.

package com.google.re2j;
package io.trino.re2j;

import com.google.re2j.DFA.DFATooManyStatesException;
import io.trino.re2j.DFA.DFATooManyStatesException;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -31,12 +31,12 @@
import io.airlift.slice.SliceOutput;
import io.airlift.slice.Slices;

import static com.google.re2j.MachineInput.EOF;
import static com.google.re2j.Options.Algorithm.DFA;
import static com.google.re2j.Options.Algorithm.DFA_FALLBACK_TO_NFA;
import static com.google.re2j.RE2.Anchor.UNANCHORED;
import static com.google.re2j.RE2.MatchKind.FIRST_MATCH;
import static com.google.re2j.RE2.MatchKind.LONGEST_MATCH;
import static io.trino.re2j.MachineInput.EOF;
import static io.trino.re2j.Options.Algorithm.DFA;
import static io.trino.re2j.Options.Algorithm.DFA_FALLBACK_TO_NFA;
import static io.trino.re2j.RE2.Anchor.UNANCHORED;
import static io.trino.re2j.RE2.MatchKind.FIRST_MATCH;
import static io.trino.re2j.RE2.MatchKind.LONGEST_MATCH;

/**
* An RE2 class instance is a compiled representation of an RE2 regular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/syntax/regexp.go

package com.google.re2j;
package io.trino.re2j;

import java.util.Arrays;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Original Go source here:
// http://code.google.com/p/go/source/browse/src/pkg/regexp/syntax/simplify.go

package com.google.re2j;
package io.trino.re2j;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.re2j;
package io.trino.re2j;

import io.airlift.slice.Slice;
import io.airlift.slice.SliceOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Original RE2 source here:
// https://github.com/google/re2/blob/master/util/sparse_set.h

package com.google.re2j;
package io.trino.re2j;

class SparseSet {
private final int[] dense; // may contain stale Entries in slots >= size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Many of these were derived from the corresponding Go functions in
// http://code.google.com/p/go/source/browse/src/pkg/unicode/letter.go

package com.google.re2j;
package io.trino.re2j;

import static java.nio.charset.StandardCharsets.UTF_8;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// go/src/pkg/unicode/maketables.go. Yes it's awful, but frankly
// it's quicker than porting 1300 more lines of Go.

package com.google.re2j;
package io.trino.re2j;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package com.google.re2j;
package io.trino.re2j;

import io.airlift.slice.Slice;

import static com.google.re2j.MachineInput.EOF;
import static io.trino.re2j.MachineInput.EOF;

/**
* Various constants and helper utilities.
Expand Down
File renamed without changes.
Loading
Loading