From efc932a7d4b46565539b031fbaece9c1d215d7f5 Mon Sep 17 00:00:00 2001 From: Willem Date: Thu, 16 Jan 2025 14:34:32 +0100 Subject: [PATCH] Moved muffin code processing to generic cake slice scanner --- .../fc18/zion7/FourCornerZionStenoLexer.java | 68 ++++++------------- .../zion7/FourCornerZionStenoLexerFire.java | 6 ++ 2 files changed, 25 insertions(+), 49 deletions(-) diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java index 26ed5c1..1509846 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java @@ -81,8 +81,11 @@ public class FourCornerZionStenoLexer { if (cakeSlice.name().startsWith("__")) { continue; // can't handle reserved, we be reported as } - if (cakeSlice.getStop() <= 0xFF) { - continue; // handle CDC and DEC and muffins manually + if (FourCornerDotCake.FC_CDC1604_P6.equals(cakeSlice)) { + continue; // handle CDC manually + } + if (FourCornerDotCake.FC_DEC0127_PX0.equals(cakeSlice)) { + continue; // handle DEC manually } if (FourCornerDotCake.FC_UNI2K_11.equals(cakeSlice)) { continue; // parse block manually @@ -101,7 +104,7 @@ public class FourCornerZionStenoLexer { } this.scanners.add(new StenoScannerWordCakeSlice(cakeSlice)); } - this.scanners.add(new StenoScannerCDCDECMuffin()); + this.scanners.add(new StenoScannerCDCDEC()); this.scanners.add(new StenoScannerNCR18()); this.scanners.add(new StenoScannerUNI21()); this.scanners.add(new StenoScannerNether()); @@ -148,21 +151,18 @@ public class FourCornerZionStenoLexer { if (cakePoint < blockStart || cakePoint > blockStop) { return ScanResult.NEXT; } + fireSignals.fireStateScanner(blockStart, blockStop, cakePoint); return process(input); } abstract ScanResult process(Iterator input); protected ScanResult safeReadCakePoints(Iterator input, List result) { - return safeReadRange(input, result, false); + return safeReadRanged(input, blockStart, blockStop, result, false); } protected ScanResult safeReadSliceOffsets(Iterator input, List result) { - return safeReadRange(input, result, true); - } - - protected ScanResult safeReadRange(Iterator input, List result, boolean offset) { - return safeReadRanged(input, blockStart, blockStop, result, offset); + return safeReadRanged(input, blockStart, blockStop, result, true); } } @@ -377,14 +377,14 @@ public class FourCornerZionStenoLexer { } } - class StenoScannerCDCDECMuffin extends StenoScanner { + class StenoScannerCDCDEC extends StenoScanner { private Integer numberMode = null; private boolean numberPIE = true; private FCDotDEC0127DashPX0 decMode = null; - public StenoScannerCDCDECMuffin() { - super(0x00, FourCornerDotCake.__MIND_THE_GAP8.getStop()); + public StenoScannerCDCDEC() { + super(FourCornerDotCake.FC_CDC1604_P6.getStart(), FourCornerDotCake.FC_DEC0127_PX0.getStop()); } @Override @@ -402,53 +402,23 @@ public class FourCornerZionStenoLexer { numberMode = null; numberPIE = true; while (cdc.hasNext()) { - Integer muffinPoint = cdc.next(); + Integer cdcDECPoint = cdc.next(); // Log state changes - if (FCDotCDC1604DashP6._NEWLINE.ordinal() == muffinPoint) { + if (FCDotCDC1604DashP6._NEWLINE.ordinal() == cdcDECPoint) { currLine++; currCol = 0; fireSignals.fireStateLine(currLine); fireSignals.fireStateColumn(currCol); } - // Handle 8 and 18 bit direct cake points - if (FourCornerDotCake.FC_APL0127_P7A.contains(muffinPoint)) { - handler.strobeWords(FourCornerDotCake.FC_APL0127_P7A, List.of(muffinPoint - FourCornerDotCake.FC_APL0127_P7A.getStart())); - continue; - } - if (FourCornerDotCake.FC_APL0127_P7B.contains(muffinPoint)) { - handler.strobeWords(FourCornerDotCake.FC_APL0127_P7B, List.of(muffinPoint - FourCornerDotCake.FC_APL0127_P7B.getStart())); - continue; - } - if (FourCornerDotCake.FC_APL0127_P7C.contains(muffinPoint)) { - handler.strobeWords(FourCornerDotCake.FC_APL0127_P7C, List.of(muffinPoint - FourCornerDotCake.FC_APL0127_P7C.getStart())); - continue; - } - if (FourCornerDotCake.FC_BYD0127_P7D.contains(muffinPoint)) { - handler.strobeWords(FourCornerDotCake.FC_BYD0127_P7D, List.of(muffinPoint - FourCornerDotCake.FC_BYD0127_P7D.getStart())); - continue; - } - if (FourCornerDotCake.FC_BYD0127_P7E.contains(muffinPoint)) { - handler.strobeWords(FourCornerDotCake.FC_BYD0127_P7E, List.of(muffinPoint - FourCornerDotCake.FC_BYD0127_P7E.getStart())); - continue; - } - if (FourCornerDotCake.FC_BYD0127_P7F.contains(muffinPoint)) { - handler.strobeWords(FourCornerDotCake.FC_BYD0127_P7F, List.of(muffinPoint - FourCornerDotCake.FC_BYD0127_P7F.getStart())); - continue; - } - if (FourCornerDotCake.__MIND_THE_GAP8.contains(muffinPoint)) { - smokeSignals.burnUnsupported(currLine, currCol, cakePoint); - continue; - } - if (handlerEscape) { - // Handle 6 bit CDC and DEC 6/8/18 codes - handleCDCDEC(cdc, muffinPoint, null); - } else if (FourCornerDotCake.FC_DEC0127_PX0.contains(muffinPoint)) { + // Handle 6 bit CDC and DEC codes + handleCDCDEC(cdc, cdcDECPoint, null); + } else if (FourCornerDotCake.FC_DEC0127_PX0.contains(cdcDECPoint)) { // No escaping, print DEC code for 8 and 18 bit - handler.strobeWords(FourCornerDotCake.FC_DEC0127_PX0, List.of(muffinPoint - FourCornerDotCake.FC_DEC0127_PX0.getStart())); + handler.strobeWords(FourCornerDotCake.FC_DEC0127_PX0, List.of(cdcDECPoint - FourCornerDotCake.FC_DEC0127_PX0.getStart())); } else { // No escaping, print CDC code - handler.strobeWords(FourCornerDotCake.FC_CDC1604_P6, List.of(muffinPoint)); + handler.strobeWords(FourCornerDotCake.FC_CDC1604_P6, List.of(cdcDECPoint)); } } } diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java index 466adae..bc79aa9 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java @@ -32,6 +32,8 @@ public interface FourCornerZionStenoLexerFire { void fireStateColumn(int column); + void fireStateScanner(int blockStart, int blockStop, int cakePoint); + interface Adapter extends FourCornerZionStenoLexerFire { @Override @@ -41,5 +43,9 @@ public interface FourCornerZionStenoLexerFire { @Override default void fireStateColumn(int column) { } + + @Override + default void fireStateScanner(int blockStart, int blockStop, int cakePoint) { + } } }