-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Update Larky to enable parity (#55)
* Checkpoint * Fixes #28 * Add struct constructor enhancement and allow EvalException to propogate upwards * Fixes #51 * Updated larky to use re2.split() to match the python re module * wrap regular expression in namedtuple * regular expression tests fully working * Allow building java 1.8 with java 11 and allow building with java8 as well * Restructure the larky project. Fixes #18.
- Loading branch information
1 parent
d62dd8c
commit 377a976
Showing
39 changed files
with
1,734 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
larky/src/main/java/com/verygood/security/larky/modules/RegexModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.verygood.security.larky.modules; | ||
|
||
import com.verygood.security.larky.modules.re.RegexPattern; | ||
|
||
import net.starlark.java.annot.StarlarkBuiltin; | ||
import net.starlark.java.annot.StarlarkMethod; | ||
import net.starlark.java.eval.StarlarkValue; | ||
|
||
|
||
@StarlarkBuiltin( | ||
name = "re2j", | ||
category = "BUILTIN", | ||
doc = "This module provides access to the linear regular expression matching engine.\n" + | ||
"\n" + | ||
"This package provides an implementation of regular expression matching based on Russ Cox's linear-time RE2 algorithm.\n" + | ||
"\n" + | ||
"The API presented by com.google.re2j mimics that of java.util.regex.Matcher and java.util.regex.Pattern. While not identical, they are similar enough that most users can switch implementations simply by changing their imports.\n" + | ||
"\n" + | ||
"The syntax of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages. More precisely, it is the syntax accepted by the C++ and Go implementations of RE2 described at https://github.com/google/re2/wiki/Syntax, except for \\C (match any byte), which is not supported because in this implementation, the matcher's input is conceptually a stream of Unicode code points, not bytes.\n" + | ||
"\n" + | ||
"The current API is rather small and intended for compatibility with java.util.regex, but the underlying implementation supports some additional features, such as the ability to process input character streams encoded as UTF-8 byte arrays. These may be exposed in a future release if there is sufficient interest." + | ||
"\n" + | ||
"More on syntax here: https://github.com/google/re2/wiki/Syntax") | ||
public class RegexModule implements StarlarkValue { | ||
|
||
public static final RegexModule INSTANCE = new RegexModule(); | ||
|
||
private static final RegexPattern _Pattern = new RegexPattern(); | ||
|
||
@StarlarkMethod(name = "Pattern", doc = "pattern", structField = true) | ||
public static RegexPattern Pattern() { return _Pattern; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.