Added invalid NCR smoke signal support
This commit is contained in:
parent
639ff340fd
commit
b8139ebda0
|
@ -137,7 +137,7 @@ public class FourCornerUnicodeDisplay {
|
|||
lexer.withSmokeSignals(printer).read(chars);
|
||||
}
|
||||
|
||||
private final class StenoUnicodePrinter implements FourCornerZion7Candlelier, FourCornerZionStenoLexerSmoke {
|
||||
private final class StenoUnicodePrinter implements FourCornerZion7Candlelier, FourCornerZionStenoLexerSmoke.Adapter {
|
||||
|
||||
private final StringBuilder output;
|
||||
|
||||
|
|
|
@ -42,4 +42,23 @@ public interface FourCornerZion7Candlelier {
|
|||
void strobeUnicode(List<Integer> codePoints);
|
||||
|
||||
void strobeNether(List<Integer> key, List<Integer> octals);
|
||||
|
||||
interface Adapter extends FourCornerZion7Candlelier {
|
||||
|
||||
@Override
|
||||
default void strobeWords(FourCornerDotCake slice, List<Integer> offsets) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void strobeNCR1632(BigInteger denominator, BigInteger numerator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void strobeUnicode(List<Integer> codePoints) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void strobeNether(List<Integer> key, List<Integer> octals) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,22 +79,22 @@ public class FourCornerZionStenoLexer {
|
|||
continue; // can't handle reserved, we be reported as
|
||||
}
|
||||
if (cakeSlice.getStop() <= 0xFF) {
|
||||
continue; // handle CDC and DEC and muffins manual
|
||||
continue; // handle CDC and DEC and muffins manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_UNI2K_11.equals(cakeSlice)) {
|
||||
continue; // parse blocks manual
|
||||
continue; // parse block manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_UNI2K_22.equals(cakeSlice)) {
|
||||
continue; // parse blocks manual
|
||||
continue; // parse block manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_NETHER.equals(cakeSlice)) {
|
||||
continue; // merge the nether data to octals manual
|
||||
continue; // merge the nether data to octals manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_NCR1632_XD.equals(cakeSlice)) {
|
||||
continue; // merge the nether data to octals manual
|
||||
continue; // parse block manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_NCR1632_XN.equals(cakeSlice)) {
|
||||
continue; // merge the nether data to octals manual
|
||||
continue; // parse block manually
|
||||
}
|
||||
this.scanners.add(new StenoScannerWordCakeSlice(cakeSlice));
|
||||
}
|
||||
|
@ -282,6 +282,7 @@ public class FourCornerZionStenoLexer {
|
|||
private void handlePoints(List<Integer> slicedPoints) {
|
||||
int denominatorBank[] = new int[64]; // <== is the terminator select per 9 bit group
|
||||
int numeratorBank[] = new int[64];
|
||||
boolean fired = false;
|
||||
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();
|
||||
|
@ -303,6 +304,10 @@ public class FourCornerZionStenoLexer {
|
|||
numerator = numerator.add(BigInteger.valueOf(numeratorBank[i]).shiftLeft(i*9));
|
||||
}
|
||||
handler.strobeNCR1632(denominator, numerator);
|
||||
fired = true;
|
||||
}
|
||||
if (fired == false && smokeSignals != null) {
|
||||
smokeSignals.burnInvalidNCR1632(currLine, currCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,15 +28,36 @@ package org.x4o.o2o.fc18.zion7;
|
|||
/// @version 1.0 Jan 12, 2025
|
||||
public interface FourCornerZionStenoLexerSmoke {
|
||||
|
||||
default void burnUnsupported(int line, int col, int cakePoint) {
|
||||
}
|
||||
void burnUnsupported(int line, int col, int cakePoint);
|
||||
|
||||
default void burnRecursive(int line, int col) {
|
||||
}
|
||||
void burnRecursive(int line, int col);
|
||||
|
||||
default void burnInvalidSalah(int line, int col) {
|
||||
}
|
||||
void burnInvalidSalah(int line, int col);
|
||||
|
||||
default void burnInvalidEscape(int line, int col, int cakePoint) {
|
||||
void burnInvalidEscape(int line, int col, int cakePoint);
|
||||
|
||||
void burnInvalidNCR1632(int line, int col);
|
||||
|
||||
interface Adapter extends FourCornerZionStenoLexerSmoke {
|
||||
|
||||
@Override
|
||||
default void burnUnsupported(int line, int col, int cakePoint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnRecursive(int line, int col) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnInvalidSalah(int line, int col) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnInvalidEscape(int line, int col, int cakePoint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnInvalidNCR1632(int line, int col) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,55 +40,6 @@ import org.x4o.o2o.fc18.zero33.FCDotDEC0127DashPX0;
|
|||
*/
|
||||
public class FourCornerUnicodeDisplayTest {
|
||||
|
||||
@Test
|
||||
public void testNCRSimpleX06() throws Exception {
|
||||
List<FourCornerX06BaklavaPoints> cdc = new ArrayList<>();
|
||||
cdc.add(FCDotCDC1604DashP6.NX24_X); // = X
|
||||
cdc.add(FCDotCDC1604DashP6.EQUALS);
|
||||
cdc.addAll(FCDotDEC0127DashPX0.ESC68_NCR.toX06BaklavaPoints());
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // T015
|
||||
cdc.add(FCDotCDC1604DashP6.NX14_N); // NXX_014
|
||||
cdc.add(FCDotCDC1604DashP6.NX05_E); // NXX_005
|
||||
cdc.add(FCDotCDC1604DashP6.NX07_G); // NXX_007
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // NXX_015
|
||||
cdc.add(FCDotCDC1604DashP6.NX04_D); // NXX_004
|
||||
cdc.add(FCDotCDC1604DashP6.SEMICOLON);
|
||||
cdc.add(FCDotCDC1604DashP6._NEWLINE);
|
||||
|
||||
Assertions.assertEquals("X=¹⁴/₁₅⁵/₁₅⁷/₁₅¹⁵/₁₅⁴/₁₅;\n", FourCornerUnicodeDisplay.text().renderFromX06(cdc));
|
||||
Assertions.assertEquals("X=␃␃␂ONEGOD;\n", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRLargeF9() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(FCDotCDC1604DashP6.NX24_X.ordinal()); // = X
|
||||
cdc.add(FCDotCDC1604DashP6.EQUALS.ordinal());
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 11); // NXX_011
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart()); // T001
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart()); // NXX_001
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() - 1 + 15); // T015
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 14); // NXX_014
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() - 1 + 1); // one
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + 512 + 2); // T1024 + one
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 4); // NXX_004
|
||||
cdc.add(FCDotCDC1604DashP6.SEMICOLON.ordinal());
|
||||
cdc.add(FCDotCDC1604DashP6._NEWLINE.ordinal());
|
||||
|
||||
Assertions.assertEquals("X=¹¹/₁¹/₁¹⁴/₁₅¹²³/₁₀₂₅⁴/₁₀₂₅;\n", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRLargestF576() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 1);
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
||||
|
||||
String res = "¹²³/₄₈₃₀₆₇₁₉₀₃₇₇₁₅₇₂₉₃₀₈₆₉₁₈₉₈₆₃₆₆₄₉₈₄₁₈₀₃₇₃₆₅₉₁₆₂₁₃₃₀₄₃₇₄₈₃₂₁₅₄₄₀₆₄₃₁₄₃₉₈₉₂₇₈₆₁₉₅₀₅₃₀₆₇₀₂₄₂₂₀₈₂₂₇₄₀₃₂₂₂₄₅₃₀₇₉₅₂₀₀₃₉₃₇₇₇₂₁₄₇₁₇₀₆₃₄₈₃₂₆₃₀₃₇₃₄₅₆₉₆₇₈₆₃₅₈₄₁₈₃₃₈₅₀₉₃₅₈₇₁₂₂₆₀₁₈₅₂₉₂₉";
|
||||
Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMixedCasing() throws Exception {
|
||||
List<FourCornerX06BaklavaPoints> cdc = new ArrayList<>();
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* 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.o2o.fc18.zion7;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.x4o.o2o.fc18.FourCornerDotCake;
|
||||
import org.x4o.o2o.fc18.FourCornerUnicodeDisplay;
|
||||
import org.x4o.o2o.fc18.FourCornerUnicodeImport;
|
||||
import org.x4o.o2o.fc18.FourCornerX06BaklavaPoints;
|
||||
import org.x4o.o2o.fc18.pie9c.FCDotPIE9CDash26;
|
||||
import org.x4o.o2o.fc18.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.o2o.fc18.zero33.FCDotDEC0127DashPX0;
|
||||
|
||||
/**
|
||||
* Tests four corner lexer parts.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 14, 2025
|
||||
*/
|
||||
public class LexerNCRTest {
|
||||
|
||||
int errorLine = -1;
|
||||
|
||||
@Test
|
||||
public void testNCRInvalid() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 1);
|
||||
//cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
||||
|
||||
FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true);
|
||||
lexer.withSmokeSignals(new FourCornerZionStenoLexerSmoke.Adapter() {
|
||||
@Override
|
||||
public void burnInvalidNCR1632(int line, int col) {
|
||||
errorLine = line;
|
||||
}
|
||||
}).read(cdc);
|
||||
Assertions.assertEquals(0, errorLine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRSimpleX06() throws Exception {
|
||||
List<FourCornerX06BaklavaPoints> cdc = new ArrayList<>();
|
||||
cdc.add(FCDotCDC1604DashP6.NX24_X); // = X
|
||||
cdc.add(FCDotCDC1604DashP6.EQUALS);
|
||||
cdc.addAll(FCDotDEC0127DashPX0.ESC68_NCR.toX06BaklavaPoints());
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // T015
|
||||
cdc.add(FCDotCDC1604DashP6.NX14_N); // NXX_014
|
||||
cdc.add(FCDotCDC1604DashP6.NX05_E); // NXX_005
|
||||
cdc.add(FCDotCDC1604DashP6.NX07_G); // NXX_007
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // NXX_015
|
||||
cdc.add(FCDotCDC1604DashP6.NX04_D); // NXX_004
|
||||
cdc.add(FCDotCDC1604DashP6.SEMICOLON);
|
||||
cdc.add(FCDotCDC1604DashP6._NEWLINE);
|
||||
|
||||
Assertions.assertEquals("X=¹⁴/₁₅⁵/₁₅⁷/₁₅¹⁵/₁₅⁴/₁₅;\n", FourCornerUnicodeDisplay.text().renderFromX06(cdc));
|
||||
Assertions.assertEquals("X=␃␃␂ONEGOD;\n", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRLargeF9() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(FCDotCDC1604DashP6.NX24_X.ordinal()); // = X
|
||||
cdc.add(FCDotCDC1604DashP6.EQUALS.ordinal());
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 11); // NXX_011
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart()); // T001
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart()); // NXX_001
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() - 1 + 15); // T015
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 14); // NXX_014
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() - 1 + 1); // one
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + 512 + 2); // T1024 + one
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 4); // NXX_004
|
||||
cdc.add(FCDotCDC1604DashP6.SEMICOLON.ordinal());
|
||||
cdc.add(FCDotCDC1604DashP6._NEWLINE.ordinal());
|
||||
|
||||
Assertions.assertEquals("X=¹¹/₁¹/₁¹⁴/₁₅¹²³/₁₀₂₅⁴/₁₀₂₅;\n", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRLargestF576() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 1);
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
||||
|
||||
String res = "¹²³/₄₈₃₀₆₇₁₉₀₃₇₇₁₅₇₂₉₃₀₈₆₉₁₈₉₈₆₃₆₆₄₉₈₄₁₈₀₃₇₃₆₅₉₁₆₂₁₃₃₀₄₃₇₄₈₃₂₁₅₄₄₀₆₄₃₁₄₃₉₈₉₂₇₈₆₁₉₅₀₅₃₀₆₇₀₂₄₂₂₀₈₂₂₇₄₀₃₂₂₂₄₅₃₀₇₉₅₂₀₀₃₉₃₇₇₇₂₁₄₇₁₇₀₆₃₄₈₃₂₆₃₀₃₇₃₄₅₆₉₆₇₈₆₃₅₈₄₁₈₃₃₈₅₀₉₃₅₈₇₁₂₂₆₀₁₈₅₂₉₂₉";
|
||||
Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue