[jruby-joni] 132/194: move reduce table to quantifier node
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:34 UTC 2018
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 2fc293fc21e8b8ad45843e0e98534c9ea3d913fb
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Tue Jan 9 23:06:43 2018 +0100
move reduce table to quantifier node
---
src/org/joni/ast/QuantifierNode.java | 44 +++++++++++++++++++++-----
src/org/joni/constants/Reduce.java | 61 ------------------------------------
2 files changed, 36 insertions(+), 69 deletions(-)
diff --git a/src/org/joni/ast/QuantifierNode.java b/src/org/joni/ast/QuantifierNode.java
index d623a30..3837e43 100644
--- a/src/org/joni/ast/QuantifierNode.java
+++ b/src/org/joni/ast/QuantifierNode.java
@@ -19,9 +19,16 @@
*/
package org.joni.ast;
+import static org.joni.ast.QuantifierNode.ReduceType.A;
+import static org.joni.ast.QuantifierNode.ReduceType.AQ;
+import static org.joni.ast.QuantifierNode.ReduceType.ASIS;
+import static org.joni.ast.QuantifierNode.ReduceType.DEL;
+import static org.joni.ast.QuantifierNode.ReduceType.PQ_Q;
+import static org.joni.ast.QuantifierNode.ReduceType.P_QQ;
+import static org.joni.ast.QuantifierNode.ReduceType.QQ;
+
import org.joni.Config;
import org.joni.ScanEnvironment;
-import org.joni.constants.Reduce;
import org.joni.constants.TargetInfo;
public final class QuantifierNode extends StateNode {
@@ -123,13 +130,33 @@ public final class QuantifierNode extends StateNode {
combExpCheckNum = other.combExpCheckNum;
}
+ enum ReduceType {
+ ASIS, /* as is */
+ DEL, /* delete parent */
+ A, /* to '*' */
+ AQ, /* to '*?' */
+ QQ, /* to '??' */
+ P_QQ, /* to '+)??' */
+ PQ_Q, /* to '+?)?' */
+ }
+
+ final ReduceType[][]REDUCE_TABLE = {
+ {DEL, A, A, QQ, AQ, ASIS}, /* '?' */
+ {DEL, DEL, DEL, P_QQ, P_QQ, DEL}, /* '*' */
+ {A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */
+ {DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */
+ {DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */
+ {ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */
+ };
+
+
public void reduceNestedQuantifier(QuantifierNode other) {
int pnum = popularNum();
int cnum = other.popularNum();
if (pnum < 0 || cnum < 0) return;
- switch(Reduce.REDUCE_TABLE[cnum][pnum]) {
+ switch(REDUCE_TABLE[cnum][pnum]) {
case DEL:
// no need to set the parent here...
copy(other);
@@ -184,6 +211,9 @@ public final class QuantifierNode extends StateNode {
other.target = null; // remove target from reduced quantifier
}
+ final String PopularQStr[] = new String[] {"?", "*", "+", "??", "*?", "+?"};
+ final String ReduceQStr[]= new String[] {"", "", "*", "*?", "??", "+ and ??", "+? and ?"};
+
public int setQuantifier(Node tgt, boolean group, ScanEnvironment env, byte[]bytes, int p, int end) {
if (lower == 1 && upper == 1) {
if (env.syntax.op3OptionECMAScript()) {
@@ -216,20 +246,18 @@ public final class QuantifierNode extends StateNode {
if (Config.USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR) {
if (!isByNumber() && !qnt.isByNumber() && env.syntax.warnReduntantNestedRepeat()) {
- switch(Reduce.REDUCE_TABLE[targetQNum][nestQNum]) {
+ switch(REDUCE_TABLE[targetQNum][nestQNum]) {
case ASIS:
break;
-
case DEL:
env.reg.warnings.warn(new String(bytes, p, end) +
" redundant nested repeat operator");
break;
-
default:
env.reg.warnings.warn(new String(bytes, p, end) +
- " nested repeat operator " + Reduce.PopularQStr[targetQNum] +
- " and " + Reduce.PopularQStr[nestQNum] + " was replaced with '" +
- Reduce.ReduceQStr[Reduce.REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'");
+ " nested repeat operator " + PopularQStr[targetQNum] +
+ " and " + PopularQStr[nestQNum] + " was replaced with '" +
+ ReduceQStr[REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'");
}
}
} // USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
diff --git a/src/org/joni/constants/Reduce.java b/src/org/joni/constants/Reduce.java
deleted file mode 100644
index 07b5e18..0000000
--- a/src/org/joni/constants/Reduce.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is furnished to do
- * so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package org.joni.constants;
-
-import static org.joni.constants.Reduce.ReduceType.A;
-import static org.joni.constants.Reduce.ReduceType.AQ;
-import static org.joni.constants.Reduce.ReduceType.ASIS;
-import static org.joni.constants.Reduce.ReduceType.DEL;
-import static org.joni.constants.Reduce.ReduceType.PQ_Q;
-import static org.joni.constants.Reduce.ReduceType.P_QQ;
-import static org.joni.constants.Reduce.ReduceType.QQ;
-
-public interface Reduce {
-
- enum ReduceType {
- ASIS, /* as is */
- DEL, /* delete parent */
- A, /* to '*' */
- AQ, /* to '*?' */
- QQ, /* to '??' */
- P_QQ, /* to '+)??' */
- PQ_Q, /* to '+?)?' */
- }
-
- final ReduceType[][]REDUCE_TABLE = {
- {DEL, A, A, QQ, AQ, ASIS}, /* '?' */
- {DEL, DEL, DEL, P_QQ, P_QQ, DEL}, /* '*' */
- {A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */
- {DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */
- {DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */
- {ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */
- };
-
-
- final String PopularQStr[] = new String[] {
- "?", "*", "+", "??", "*?", "+?"
- };
-
- String ReduceQStr[]= new String[] {
- "", "", "*", "*?", "??", "+ and ??", "+? and ?"
- };
-
-}
-
--
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