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 1509846..e4fa576 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 @@ -284,6 +284,9 @@ public class FourCornerZionStenoLexer { class StenoScannerNCR18 extends StenoScanner { + private final int denominatorBank[] = new int[64]; // <== is the terminator select per 9 bit group + private final int numeratorBank[] = new int[64]; + public StenoScannerNCR18() { super(FourCornerDotCake.FC_NCR1632_XD.getStart(), FourCornerDotCake.FC_NCR1632_XN.getStop()); } @@ -299,42 +302,51 @@ public class FourCornerZionStenoLexer { } private void handlePoints(List slicedPoints) { - int denominatorBank[] = new int[64]; // <== is the terminator select per 9 bit group - int numeratorBank[] = new int[64]; - boolean errorZeroSparks = true; - boolean errorUnusedSparks = true; + bankReset(); + boolean magicSparkler = true; for (Integer cakePoint : slicedPoints) { if (cakePoint >= FourCornerDotCake.FC_NCR1632_XD.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_XD.getStop()) { int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_XD.getStart(); denominatorBank[denominatorX / 512] = denominatorX % 512; - errorUnusedSparks = true; + magicSparkler = true; continue; } int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_XN.getStart(); numeratorBank[numeratorX / 512] = numeratorX % 512; if (cakePoint > FourCornerDotCake.FC_NCR1632_XN.getStart() + 512) { - errorUnusedSparks = true; + magicSparkler = true; continue; // Only fire fraction on lowest value select } - BigInteger denominator = BigInteger.ONE; - for (int i=0; i cdc = new ArrayList<>(); - cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 1); + cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*3) + 1); /// auto NXX_001 + cdc.addAll(FCDotDEC0127DashPX0.ESC_STOP.toInt18BaklavaPoints()); + Assertions.assertEquals(0, fireWalker.ncrMagicSparks); lexer.read(cdc); - Assertions.assertEquals(-1, smokeReader.errorNCRUnusedSparks); - Assertions.assertEquals(0, smokeReader.errorNCRZeroSparks); + Assertions.assertEquals(1, fireWalker.ncrMagicSparks); - cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123 - cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 2); + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // normal NXX_123 + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*4) + 2); /// auto NXX_123 + this - smokeReader.reset(); + fireWalker.reset(); lexer.read(cdc); - Assertions.assertEquals(0, smokeReader.errorNCRUnusedSparks); - Assertions.assertEquals(-1, smokeReader.errorNCRZeroSparks); + Assertions.assertEquals(2, fireWalker.ncrMagicSparks); + + Assertions.assertEquals("¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁵⁹⁵/₁", FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); } @Test diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestFireWalker.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestFireWalker.java new file mode 100644 index 0000000..70992b9 --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestFireWalker.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2004-2014, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.x4o.fc18.zion7; + +/** + * Walks four corner lexer fire signals. + * + * @author Willem Cazander + * @version 1.0 Jan 16, 2025 + */ +public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter { + + int currentLine; + int currentColumn; + int scanBlockStart; + int scanBlockStop; + int scanCakePoint; + int ncrMagicSparks; + + public TestFireWalker() { + reset(); + } + + public void reset() { + currentLine = 0; + currentColumn = 0; + scanBlockStart = 0; + ncrMagicSparks = 0; + } + + @Override + public void fireStateLine(int line) { + currentLine = line; + } + + @Override + public void fireStateColumn(int column) { + currentColumn = column; + } + + @Override + public void fireStateScanner(int blockStart, int blockStop, int cakePoint) { + scanBlockStart = blockStart; + scanBlockStop = blockStop; + scanCakePoint = cakePoint; + } + + @Override + public void fireStateNCR1632Sparkler() { + ncrMagicSparks++; + } +} diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestSmokeReader.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestSmokeReader.java index d69a1c8..6cba301 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestSmokeReader.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestSmokeReader.java @@ -23,15 +23,13 @@ package org.x4o.fc18.zion7; /** - * Tests four corner lexer parts. + * Reads four corner lexer smoke signals. * * @author Willem Cazander * @version 1.0 Jan 14, 2025 */ public class TestSmokeReader implements FourCornerZionStenoLexerSmoke.Adapter { - int errorNCRZeroSparks; - int errorNCRUnusedSparks; int errorUNI21UnusedBigIndian; int errorUnsupport; int errorRecursive; @@ -41,23 +39,11 @@ public class TestSmokeReader implements FourCornerZionStenoLexerSmoke.Adapter { } public void reset() { - errorNCRZeroSparks = -1; - errorNCRUnusedSparks = -1; errorUNI21UnusedBigIndian = -1; errorUnsupport = -1; errorRecursive = -1; } - @Override - public void burnNCR1632ZeroSparks(int line, int col) { - errorNCRZeroSparks = line; - } - - @Override - public void burnNCR1632UnusedSparks(int line, int col) { - errorNCRUnusedSparks = line; - } - @Override public void burnUNI21UnusedBigIndian(int line, int col) { errorUNI21UnusedBigIndian = line;