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 2838d87437ae440301c3ec9cc352f059f444eb83 Author: Marcin Mielzynski <l...@gazeta.pl> Date: Sat Dec 30 13:46:52 2017 +0100 move isInvalidQuantifier to Parser --- src/org/joni/Parser.java | 37 +++++++++++++++++++++++++++++++++++-- src/org/joni/ast/Node.java | 36 ------------------------------------ 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/org/joni/Parser.java b/src/org/joni/Parser.java index dab14c1..ea36575 100644 --- a/src/org/joni/Parser.java +++ b/src/org/joni/Parser.java @@ -1337,7 +1337,7 @@ class Parser extends Lexer { private Node parseExpRepeat(Node target, boolean group) { while (token.type == TokenType.OP_REPEAT || token.type == TokenType.INTERVAL) { // repeat: - if (target.isInvalidQuantifier()) newSyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID); + if (isInvalidQuantifier(target)) newSyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID); if (!group && syntax.op2OptionECMAScript() && target.getType() == NodeType.QTFR) { newSyntaxException(ERR_NESTED_REPEAT_NOT_ALLOWED); @@ -1372,7 +1372,7 @@ class Parser extends Lexer { private Node parseExpRepeatForCar(Node top, ConsAltNode target, boolean group) { while (token.type == TokenType.OP_REPEAT || token.type == TokenType.INTERVAL) { // repeat: - if (target.car.isInvalidQuantifier()) newSyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID); + if (isInvalidQuantifier(target.car)) newSyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID); QuantifierNode qtfr = new QuantifierNode(token.getRepeatLower(), token.getRepeatUpper(), @@ -1398,6 +1398,39 @@ class Parser extends Lexer { return top; } + private boolean isInvalidQuantifier(Node node) { + if (Config.USE_NO_INVALID_QUANTIFIER) return false; + + ConsAltNode consAlt; + switch(node.getType()) { + case NodeType.ANCHOR: + return true; + + case NodeType.ENCLOSE: + /* allow enclosed elements */ + /* return is_invalid_quantifier_target(NENCLOSE(node)->target); */ + break; + + case NodeType.LIST: + consAlt = (ConsAltNode)node; + do { + if (!isInvalidQuantifier(consAlt.car)) return false; + } while ((consAlt = consAlt.cdr) != null); + return false; + + case NodeType.ALT: + consAlt = (ConsAltNode)node; + do { + if (isInvalidQuantifier(consAlt.car)) return true; + } while ((consAlt = consAlt.cdr) != null); + break; + + default: + break; + } + return false; + } + private Node parseCodePoint() { byte[]buf = new byte[Config.ENC_CODE_TO_MBC_MAXLEN]; int num = enc.codeToMbc(token.getCode(), buf, 0); diff --git a/src/org/joni/ast/Node.java b/src/org/joni/ast/Node.java index 824e651..96890f8 100644 --- a/src/org/joni/ast/Node.java +++ b/src/org/joni/ast/Node.java @@ -89,42 +89,6 @@ public abstract class Node implements NodeType { return value.toString().replace("\n", "\n" + pad); } - public final boolean isInvalidQuantifier() { - if (Config.USE_NO_INVALID_QUANTIFIER) return false; - - ConsAltNode node; - - switch(getType()) { - - case ANCHOR: - return true; - - case ENCLOSE: - /* allow enclosed elements */ - /* return is_invalid_quantifier_target(NENCLOSE(node)->target); */ - break; - - case LIST: - node = (ConsAltNode)this; - do { - if (!node.car.isInvalidQuantifier()) return false; - } while ((node = node.cdr) != null); - return false; - - case ALT: - node = (ConsAltNode)this; - do { - if (node.car.isInvalidQuantifier()) return true; - } while ((node = node.cdr) != null); - break; - - default: - break; - } - - return false; - } - public final boolean isAllowedInLookBehind() { return (getType2Bit() & ALLOWED_IN_LB) != 0; } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git _______________________________________________ pkg-java-commits mailing list pkg-java-comm...@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits