Moved muffin code processing to generic cake slice scanner

This commit is contained in:
Willem Cazander 2025-01-16 14:34:32 +01:00
parent 619f01906f
commit efc932a7d4
2 changed files with 25 additions and 49 deletions

View file

@ -81,8 +81,11 @@ public class FourCornerZionStenoLexer {
if (cakeSlice.name().startsWith("__")) { if (cakeSlice.name().startsWith("__")) {
continue; // can't handle reserved, we be reported as continue; // can't handle reserved, we be reported as
} }
if (cakeSlice.getStop() <= 0xFF) { if (FourCornerDotCake.FC_CDC1604_P6.equals(cakeSlice)) {
continue; // handle CDC and DEC and muffins manually continue; // handle CDC manually
}
if (FourCornerDotCake.FC_DEC0127_PX0.equals(cakeSlice)) {
continue; // handle DEC manually
} }
if (FourCornerDotCake.FC_UNI2K_11.equals(cakeSlice)) { if (FourCornerDotCake.FC_UNI2K_11.equals(cakeSlice)) {
continue; // parse block manually continue; // parse block manually
@ -101,7 +104,7 @@ public class FourCornerZionStenoLexer {
} }
this.scanners.add(new StenoScannerWordCakeSlice(cakeSlice)); 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 StenoScannerNCR18());
this.scanners.add(new StenoScannerUNI21()); this.scanners.add(new StenoScannerUNI21());
this.scanners.add(new StenoScannerNether()); this.scanners.add(new StenoScannerNether());
@ -148,21 +151,18 @@ public class FourCornerZionStenoLexer {
if (cakePoint < blockStart || cakePoint > blockStop) { if (cakePoint < blockStart || cakePoint > blockStop) {
return ScanResult.NEXT; return ScanResult.NEXT;
} }
fireSignals.fireStateScanner(blockStart, blockStop, cakePoint);
return process(input); return process(input);
} }
abstract ScanResult process(Iterator<Integer> input); abstract ScanResult process(Iterator<Integer> input);
protected ScanResult safeReadCakePoints(Iterator<Integer> input, List<Integer> result) { protected ScanResult safeReadCakePoints(Iterator<Integer> input, List<Integer> result) {
return safeReadRange(input, result, false); return safeReadRanged(input, blockStart, blockStop, result, false);
} }
protected ScanResult safeReadSliceOffsets(Iterator<Integer> input, List<Integer> result) { protected ScanResult safeReadSliceOffsets(Iterator<Integer> input, List<Integer> result) {
return safeReadRange(input, result, true); return safeReadRanged(input, blockStart, blockStop, result, true);
}
protected ScanResult safeReadRange(Iterator<Integer> input, List<Integer> result, boolean offset) {
return safeReadRanged(input, blockStart, blockStop, result, offset);
} }
} }
@ -377,14 +377,14 @@ public class FourCornerZionStenoLexer {
} }
} }
class StenoScannerCDCDECMuffin extends StenoScanner { class StenoScannerCDCDEC extends StenoScanner {
private Integer numberMode = null; private Integer numberMode = null;
private boolean numberPIE = true; private boolean numberPIE = true;
private FCDotDEC0127DashPX0 decMode = null; private FCDotDEC0127DashPX0 decMode = null;
public StenoScannerCDCDECMuffin() { public StenoScannerCDCDEC() {
super(0x00, FourCornerDotCake.__MIND_THE_GAP8.getStop()); super(FourCornerDotCake.FC_CDC1604_P6.getStart(), FourCornerDotCake.FC_DEC0127_PX0.getStop());
} }
@Override @Override
@ -402,53 +402,23 @@ public class FourCornerZionStenoLexer {
numberMode = null; numberMode = null;
numberPIE = true; numberPIE = true;
while (cdc.hasNext()) { while (cdc.hasNext()) {
Integer muffinPoint = cdc.next(); Integer cdcDECPoint = cdc.next();
// Log state changes // Log state changes
if (FCDotCDC1604DashP6._NEWLINE.ordinal() == muffinPoint) { if (FCDotCDC1604DashP6._NEWLINE.ordinal() == cdcDECPoint) {
currLine++; currLine++;
currCol = 0; currCol = 0;
fireSignals.fireStateLine(currLine); fireSignals.fireStateLine(currLine);
fireSignals.fireStateColumn(currCol); 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) { if (handlerEscape) {
// Handle 6 bit CDC and DEC 6/8/18 codes // Handle 6 bit CDC and DEC codes
handleCDCDEC(cdc, muffinPoint, null); handleCDCDEC(cdc, cdcDECPoint, null);
} else if (FourCornerDotCake.FC_DEC0127_PX0.contains(muffinPoint)) { } else if (FourCornerDotCake.FC_DEC0127_PX0.contains(cdcDECPoint)) {
// No escaping, print DEC code for 8 and 18 bit // 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 { } else {
// No escaping, print CDC code // No escaping, print CDC code
handler.strobeWords(FourCornerDotCake.FC_CDC1604_P6, List.of(muffinPoint)); handler.strobeWords(FourCornerDotCake.FC_CDC1604_P6, List.of(cdcDECPoint));
} }
} }
} }

View file

@ -32,6 +32,8 @@ public interface FourCornerZionStenoLexerFire {
void fireStateColumn(int column); void fireStateColumn(int column);
void fireStateScanner(int blockStart, int blockStop, int cakePoint);
interface Adapter extends FourCornerZionStenoLexerFire { interface Adapter extends FourCornerZionStenoLexerFire {
@Override @Override
@ -41,5 +43,9 @@ public interface FourCornerZionStenoLexerFire {
@Override @Override
default void fireStateColumn(int column) { default void fireStateColumn(int column) {
} }
@Override
default void fireStateScanner(int blockStart, int blockStop, int cakePoint) {
}
} }
} }