Skip to content

Add support for ASCII/Unicode modifiers #13

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

Closed
chrisseaton opened this issue Dec 12, 2014 · 3 comments
Closed

Add support for ASCII/Unicode modifiers #13

chrisseaton opened this issue Dec 12, 2014 · 3 comments

Comments

@chrisseaton
Copy link

This JRuby spec https://github.com/jruby/jruby/blob/master/spec/ruby/language/regexp/modifiers_spec.rb#L103-L108 is tagged https://github.com/jruby/jruby/blob/master/spec/tags/ruby/language/regexp/modifiers_tags.txt#L1 because Joni doesn't yet have support for ASCII/Unicode modifiers. Onigmo commit: https://github.com/k-takata/Onigmo/blob/master/regparse.c#L5170.

@headius
Copy link
Member

headius commented Mar 3, 2016

I started filling in the missing group flags but did not get everything in place.

My work is in ac5ed3b.

I tracked the 'a' flag back to this commit in Onigmo:k-takata/Onigmo@52b242c

Ping @lopex!

Untested, incomplete diff that starts to fill in more blanks:

diff --git a/src/org/joni/Analyser.java b/src/org/joni/Analyser.java
index 6a4e418..9682d95 100644
--- a/src/org/joni/Analyser.java
+++ b/src/org/joni/Analyser.java
@@ -51,6 +51,7 @@ import org.joni.ast.StringNode;
 import org.joni.constants.AnchorType;
 import org.joni.constants.EncloseType;
 import org.joni.constants.NodeType;
+import org.joni.constants.OPCode;
 import org.joni.constants.StackPopLevel;
 import org.joni.constants.TargetInfo;

@@ -2100,6 +2101,38 @@ final class Analyser extends Parser {
                 opt.anchor.add(an.type);
                 break;

+            case AnchorType.WORD_BOUND:
+                if (an.asciiRange) {
+                    opt.anchor.add(OPCode.ASCII_WORD_BOUND);
+                } else {
+                    opt.anchor.add(OPCode.WORD_BOUND);
+                }
+                break;
+
+            case AnchorType.NOT_WORD_BOUND:
+                if (an.asciiRange) {
+                    opt.anchor.add(OPCode.NOT_ASCII_WORD_BOUND);
+                } else {
+                    opt.anchor.add(OPCode.NOT_WORD_BOUND);
+                }
+                break;
+
+            case AnchorType.WORD_BEGIN:
+                if (an.asciiRange) {
+                    opt.anchor.add(OPCode.ASCII_WORD_BEGIN);
+                } else {
+                    opt.anchor.add(OPCode.WORD_BEGIN);
+                }
+                break;
+
+            case AnchorType.WORD_END:
+                if (an.asciiRange) {
+                    opt.anchor.add(OPCode.ASCII_WORD_END);
+                } else {
+                    opt.anchor.add(OPCode.WORD_END);
+                }
+                break;
+
             case AnchorType.PREC_READ:
                 NodeOptInfo nopt = new NodeOptInfo();
                 optimizeNodeLeft(an.target, nopt, oenv);

@lopex
Copy link
Contributor

lopex commented Mar 6, 2016

@headius, this is going to be a tough one. This and dependent features were plagued by bugs across many commits. Now picking related ones, it's going to be a multi day effort (already have some code ported).

@lopex
Copy link
Contributor

lopex commented Dec 29, 2017

Fixed in 416f5f9 and 4e3b5cc

@lopex lopex closed this as completed Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants