[jruby-joni] 71/194: refactor analyzer construction
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:28 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 9efa27b58d2b344caf22eb2ca83b58ca03c5eb92
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Sat Dec 30 19:24:24 2017 +0100
refactor analyzer construction
---
src/org/joni/Analyser.java | 4 ++--
src/org/joni/Lexer.java | 6 +++---
src/org/joni/Parser.java | 8 +++-----
src/org/joni/Regex.java | 2 +-
src/org/joni/ScanEnvironment.java | 6 +++---
5 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/org/joni/Analyser.java b/src/org/joni/Analyser.java
index 291f056..e2f36dd 100644
--- a/src/org/joni/Analyser.java
+++ b/src/org/joni/Analyser.java
@@ -56,8 +56,8 @@ import org.joni.constants.TargetInfo;
final class Analyser extends Parser {
- protected Analyser(ScanEnvironment env, byte[]bytes, int p, int end) {
- super(env, bytes, p, end);
+ protected Analyser(Regex regex, Syntax syntax, byte[]bytes, int p, int end) {
+ super(regex, syntax, bytes, p, end);
}
protected final void compile() {
diff --git a/src/org/joni/Lexer.java b/src/org/joni/Lexer.java
index 24b5a8d..5766fd8 100644
--- a/src/org/joni/Lexer.java
+++ b/src/org/joni/Lexer.java
@@ -38,9 +38,9 @@ class Lexer extends ScannerSupport {
protected final Syntax syntax; // fast access to syntax
protected final Token token = new Token(); // current token
- protected Lexer(ScanEnvironment env, byte[]bytes, int p, int end) {
- super(env.enc, bytes, p, end);
- this.env = env;
+ protected Lexer(Regex regex, Syntax syntax, byte[]bytes, int p, int end) {
+ super(regex.enc, bytes, p, end);
+ this.env = new ScanEnvironment(regex, syntax);
this.syntax = env.syntax;
}
diff --git a/src/org/joni/Parser.java b/src/org/joni/Parser.java
index ea36575..69457d0 100644
--- a/src/org/joni/Parser.java
+++ b/src/org/joni/Parser.java
@@ -51,16 +51,14 @@ import org.joni.constants.NodeType;
import org.joni.constants.TokenType;
class Parser extends Lexer {
-
protected final Regex regex;
protected Node root;
-
protected int returnCode; // return code used by parser methods (they itself return parsed nodes)
// this approach will not affect recursive calls
- protected Parser(ScanEnvironment env, byte[]bytes, int p, int end) {
- super(env, bytes, p, end);
- regex = env.reg;
+ protected Parser(Regex regex, Syntax syntax, byte[]bytes, int p, int end) {
+ super(regex, syntax, bytes, p, end);
+ this.regex = regex;
}
// onig_parse_make_tree
diff --git a/src/org/joni/Regex.java b/src/org/joni/Regex.java
index 5edb88c..0dc21ff 100644
--- a/src/org/joni/Regex.java
+++ b/src/org/joni/Regex.java
@@ -153,7 +153,7 @@ public final class Regex {
this.caseFoldFlag = caseFoldFlag;
this.warnings = warnings;
- new Analyser(new ScanEnvironment(this, syntax), bytes, p, end).compile();
+ new Analyser(this, syntax, bytes, p, end).compile();
this.warnings = null;
}
diff --git a/src/org/joni/ScanEnvironment.java b/src/org/joni/ScanEnvironment.java
index d21e16a..8c384a6 100644
--- a/src/org/joni/ScanEnvironment.java
+++ b/src/org/joni/ScanEnvironment.java
@@ -55,10 +55,10 @@ public final class ScanEnvironment {
public ScanEnvironment(Regex regex, Syntax syntax) {
this.reg = regex;
- option = regex.options;
- caseFoldFlag = regex.caseFoldFlag;
- enc = regex.enc;
this.syntax = syntax;
+ option = reg.options;
+ caseFoldFlag = reg.caseFoldFlag;
+ enc = reg.enc;
}
public int addMemEntry() {
--
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