Made cake point block check scan in steno lexer abstract

This commit is contained in:
Willem Cazander 2025-01-16 14:15:28 +01:00
parent 3cbc754251
commit 79d8b977a6

View file

@ -130,8 +130,28 @@ public class FourCornerZionStenoLexer {
}
}
private interface StenoScanner {
ScanResult scan(Iterator<Integer> input);
abstract private class StenoScanner {
private final int blockStart;
private final int blockStop;
public StenoScanner(int blockStart, int blockStop) {
this.blockStart = blockStart;
this.blockStop = blockStop;
}
public StenoScanner(FourCornerDotCake cakeSlice) {
this(cakeSlice.getStart(), cakeSlice.getStop());
}
final public ScanResult scan(Iterator<Integer> input) {
if (cakePoint < blockStart || cakePoint > blockStop) {
return ScanResult.NEXT;
}
return process(input);
}
abstract ScanResult process(Iterator<Integer> input);
}
public void read(List<Integer> points) {
@ -216,19 +236,17 @@ public class FourCornerZionStenoLexer {
return ScanResult.DONE;
}
class StenoScannerWordCakeSlice implements StenoScanner {
class StenoScannerWordCakeSlice extends StenoScanner {
private final FourCornerDotCake cakeSlice;
public StenoScannerWordCakeSlice(FourCornerDotCake cakeSlice) {
super(cakeSlice);
this.cakeSlice = Objects.requireNonNull(cakeSlice);
}
@Override
public ScanResult scan(Iterator<Integer> input) {
if (cakeSlice.containsNot(cakePoint)) {
return ScanResult.NEXT;
}
public ScanResult process(Iterator<Integer> input) {
List<Integer> result = new ArrayList<>();
ScanResult status = safeReadSliceOffsets(input, cakeSlice.getStart(), cakeSlice.getStop(), result);
if (!result.isEmpty()) {
@ -238,13 +256,14 @@ public class FourCornerZionStenoLexer {
}
}
class StenoScannerNether implements StenoScanner {
class StenoScannerNether extends StenoScanner {
public StenoScannerNether() {
super(FourCornerDotCake.FC_NETHER);
}
@Override
public ScanResult scan(Iterator<Integer> input) {
if (FourCornerDotCake.FC_NETHER.containsNot(cakePoint)) {
return ScanResult.NEXT;
}
public ScanResult process(Iterator<Integer> input) {
List<Integer> result = new ArrayList<>();
ScanResult status = safeReadCakePoints(input, FourCornerDotCake.FC_NETHER.getStart(), FourCornerDotCake.FC_NETHER.getStop(), result);
if (!result.isEmpty()) {
@ -259,13 +278,14 @@ public class FourCornerZionStenoLexer {
}
}
class StenoScannerNCR18 implements StenoScanner {
class StenoScannerNCR18 extends StenoScanner {
public StenoScannerNCR18() {
super(FourCornerDotCake.FC_NCR1632_XD.getStart(), FourCornerDotCake.FC_NCR1632_XN.getStop());
}
@Override
public ScanResult scan(Iterator<Integer> input) {
if (cakePoint < FourCornerDotCake.FC_NCR1632_XD.getStart() || cakePoint > FourCornerDotCake.FC_NCR1632_XN.getStop()) {
return ScanResult.NEXT;
}
public ScanResult process(Iterator<Integer> input) {
List<Integer> result = new ArrayList<>();
ScanResult status = safeReadCakePoints(input, FourCornerDotCake.FC_NCR1632_XD.getStart(), FourCornerDotCake.FC_NCR1632_XN.getStop(), result);
if (!result.isEmpty()) {
@ -313,13 +333,14 @@ public class FourCornerZionStenoLexer {
}
}
class StenoScannerUNI21 implements StenoScanner {
class StenoScannerUNI21 extends StenoScanner {
public StenoScannerUNI21() {
super(FourCornerDotCake.FC_UNI2K_11.getStart(), FourCornerDotCake.FC_UNI2K_22.getStop());
}
@Override
public ScanResult scan(Iterator<Integer> input) {
if (cakePoint < FourCornerDotCake.FC_UNI2K_11.getStart() || cakePoint > FourCornerDotCake.FC_UNI2K_22.getStop()) {
return ScanResult.NEXT;
}
public ScanResult process(Iterator<Integer> input) {
List<Integer> result = new ArrayList<>();
ScanResult status = safeReadCakePoints(input, FourCornerDotCake.FC_UNI2K_11.getStart(), FourCornerDotCake.FC_UNI2K_22.getStop(), result);
if (!result.isEmpty()) {
@ -352,17 +373,18 @@ public class FourCornerZionStenoLexer {
}
}
class StenoScannerCDCDECMuffin implements StenoScanner {
class StenoScannerCDCDECMuffin extends StenoScanner {
private Integer numberMode = null;
private boolean numberPIE = true;
private FCDotDEC0127DashPX0 decMode = null;
@Override
public ScanResult scan(Iterator<Integer> input) {
if (cakePoint < FourCornerDotCake.FC_CDC1604_P6.getStart() || cakePoint > FourCornerDotCake.__MIND_THE_GAP8.getStop()) {
return ScanResult.NEXT;
public StenoScannerCDCDECMuffin() {
super(0x00, FourCornerDotCake.__MIND_THE_GAP8.getStop());
}
@Override
public ScanResult process(Iterator<Integer> input) {
List<Integer> result = new ArrayList<>();
ScanResult status = safeReadCakePoints(input, FourCornerDotCake.FC_CDC1604_P6.getStart(), FourCornerDotCake.__MIND_THE_GAP8.getStop(), result);
if (!result.isEmpty()) {