[jruby-joni] 184/279: Add OP2_ESC_IDENTITY syntax option

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:27:29 UTC 2015


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit 5f5477376112fb28e4d889479894e02744e8cd9c
Author: Ben Browning <bbrownin at redhat.com>
Date:   Mon Sep 9 20:07:07 2013 -0400

    Add OP2_ESC_IDENTITY syntax option
    
    JavaScript allows what it calls an identity escape, where an escaped
    character falls back to just returning itself if not other escape
    sequence matches.
---
 src/org/joni/Lexer.java                      | 8 +++++++-
 src/org/joni/Syntax.java                     | 7 ++++++-
 src/org/joni/constants/SyntaxProperties.java | 1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/org/joni/Lexer.java b/src/org/joni/Lexer.java
index bc919ad..e50be33 100644
--- a/src/org/joni/Lexer.java
+++ b/src/org/joni/Lexer.java
@@ -184,7 +184,13 @@ class Lexer extends ScannerSupport {
     }
 
     private void fetchEscapedValueControl() {
-        if (!left()) newSyntaxException(ERR_END_PATTERN_AT_CONTROL);
+        if (!left()) {
+            if (syntax.op2EscIdentity()) {
+                return;
+            } else {
+                newSyntaxException(ERR_END_PATTERN_AT_CONTROL);
+            }
+        }
         fetch();
         if (c == '?') {
             c = 0177;
diff --git a/src/org/joni/Syntax.java b/src/org/joni/Syntax.java
index 2827cd4..a6a729c 100644
--- a/src/org/joni/Syntax.java
+++ b/src/org/joni/Syntax.java
@@ -278,6 +278,10 @@ public final class Syntax implements SyntaxProperties{
         return isOp2(OP2_INEFFECTIVE_ESCAPE);
     }
 
+    public boolean op2EscIdentity() {
+        return isOp2(OP2_ESC_IDENTITY);
+    }
+
     /**
      * BEHAVIOR
      *
@@ -624,7 +628,8 @@ public final class Syntax implements SyntaxProperties{
         OP2_QMARK_GROUP_EFFECT | OP2_OPTION_PERL |
         OP2_ESC_P_BRACE_CHAR_PROPERTY |
         OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
-        OP2_ESC_U_HEX4 | OP2_ESC_V_VTAB ),
+        OP2_ESC_U_HEX4 | OP2_ESC_V_VTAB |
+        OP2_ESC_IDENTITY ),
 
         ( CONTEXT_INDEP_ANCHORS |
         CONTEXT_INDEP_REPEAT_OPS |
diff --git a/src/org/joni/constants/SyntaxProperties.java b/src/org/joni/constants/SyntaxProperties.java
index b31b6cb..9e783d0 100644
--- a/src/org/joni/constants/SyntaxProperties.java
+++ b/src/org/joni/constants/SyntaxProperties.java
@@ -74,6 +74,7 @@ public interface SyntaxProperties {
     /* final int OP2_CHAR_PROPERTY_PREFIX_IS = (1<<18); */
     final int OP2_ESC_H_XDIGIT               = (1<<19); /* \h, \H */
     final int OP2_INEFFECTIVE_ESCAPE         = (1<<20); /* \ */
+    final int OP2_ESC_IDENTITY               = (1<<21); /* \a, \b, \c */
 
     /* syntax (behavior); */
     final int CONTEXT_INDEP_ANCHORS           = (1<<31); /* not implemented */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list