Skip to content

Commit

Permalink
decouple CharClasses from AbstractLexScan (#652)
Browse files Browse the repository at this point in the history
* decouple CharClasses from AbstractLexScan

use UnicodeProperties directly
  • Loading branch information
lsf37 authored Dec 4, 2019
1 parent b8a891f commit 5253071
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jflex/src/main/java/jflex/core/CharClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.List;
import java.util.Objects;
import jflex.chars.Interval;
import jflex.core.unicode.UnicodeProperties;

/**
* Character Classes.
Expand All @@ -34,7 +35,8 @@ public class CharClasses {
/** the largest character actually used in a specification */
private int maxCharUsed;

public AbstractLexScan scanner; // nocommit - should be private
/** the @{link UnicodeProperties} the scanner used */
private UnicodeProperties unicodeProps;

/**
* Constructs a new CharClasses object.
Expand Down Expand Up @@ -65,7 +67,7 @@ public void init(int maxCharCode, AbstractLexScan scanner) {
}

maxCharUsed = maxCharCode;
this.scanner = scanner;
this.unicodeProps = scanner.getUnicodeProperties();
classes = new ArrayList<>();
classes.add(new IntCharSet(new Interval(0, maxCharCode)));
}
Expand Down Expand Up @@ -119,7 +121,7 @@ public int getNumClasses() {
* @param caseless if true upper/lower/title case are considered equivalent
*/
public void makeClass(IntCharSet set, boolean caseless) {
if (caseless) set = set.getCaseless(scanner.getUnicodeProperties());
if (caseless) set = set.getCaseless(unicodeProps);

if (DEBUG) {
Out.dump("makeClass(" + set + ")");
Expand Down

0 comments on commit 5253071

Please sign in to comment.