Skip to content

Conversation

@danieljaburek
Copy link
Contributor

Adding support for Java Regex in TRegex (as part of Bachelor thesis)

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Aug 12, 2022
@oracle-contributor-agreement
Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When singing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Aug 15, 2022
@djoooooe djoooooe changed the title Access TRegex from Java java.util.Pattern flavor for TRegex Aug 16, 2022
@oubidar-Abderrahim
Copy link
Member

Thank you for contributing to GraalVM, we will review your PR shortly

@oubidar-Abderrahim
Copy link
Member

oubidar-Abderrahim commented Aug 16, 2022

@djoooooe could you please assign someone to review this PR? let me know if you need me to mirror it to bitbucket. Thank you

import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;

public class JavaTruffleRegex {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused?

// String input = "hello World!";
// String input = "def=def";
String input = "abcabcabc";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove commented code and TODO comments

context = Context.newBuilder().build();
context.enter();
tregexPattern = context.eval(TRegexTestDummyLanguage.ID, '/' + reURL + '/');
tregexPattern = context.eval(TRegexTestDummyLanguage.ID, /*"Flavor=JavaUtilPattern" + */'/' + reURL + '/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

// @Benchmark
// public boolean javaPattern(BenchState state) {
// return state.javaPattern.matcher(state.input).find();
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

public void quantifiers() {
test("abc?", 0, "ab");
test("abc??", 0, "ab");
// test("abc?+c", 0, "abcc"); // not supported yet --> bailout (possive quantifiers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transform to a test that expects the bailout

parens();
break;
case '^':
case '^': // TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -0,0 +1,294 @@
package com.oracle.truffle.regex.tregex.parser;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing copyright header

private final int value;

private static final String FLAGS = "idmsuxU";
// private static final String BIT_FLAGS = "mixy";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

private void addQuantifier(Token.Quantifier quantifier) {
astBuilder.addQuantifier(quantifier);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

addDollar(); // $
nextSequence(); // |
pushLookAheadAssertion(false); // (?=
pushGroup(); // (?:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushLookAheadAssertion automatically pushes a group, no need to do that here

@djoooooe
Copy link
Member

@djoooooe could you please assign someone to review this PR? let me know if you need me to mirror it to bitbucket. Thank you

Yes, please mirror this PR to bitbucket

pushGroup(); // (?:
addCharClass(CodePointSet.create('\r'));
addCharClass(CodePointSet.create('\n'));
nextSequence();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove the corresponding popGroup(), and add a test that hits this path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants