FC18: Moved Salah Sequence interface into zion candlelier

This commit is contained in:
Willem Cazander 2025-08-21 17:37:44 +02:00
parent 61dbed85df
commit 62eca0d4b9
8 changed files with 128 additions and 47 deletions

View file

@ -24,6 +24,7 @@ package org.x4o.fc18;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.PrimitiveIterator; import java.util.PrimitiveIterator;
@ -38,6 +39,7 @@ import org.x4o.fc18.cake2.pie9c.FCDotPIE9CDash20;
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0; import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
import org.x4o.fc18.octal8.PrimordialOctal; import org.x4o.fc18.octal8.PrimordialOctal;
import org.x4o.fc18.zion7.FourCornerZion7SalahSequence;
/// Holds different lookup and conversion maps towards four corner int18 cake points. /// Holds different lookup and conversion maps towards four corner int18 cake points.
/// ///
@ -52,11 +54,55 @@ final public class FourCornerRecipe {
private FourCornerRecipe() { private FourCornerRecipe() {
} }
static public List<Integer> embedSandWalker(List<PrimordialOctal> rhythm) { static public List<Integer> embedSalahSequenceX06(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
return embedSandWalker(new ArrayList<>(), rhythm); return embedSalahSequence(new ArrayList<>(), type, arguments, true);
} }
static public List<Integer> embedSandWalker(List<Integer> out, List<PrimordialOctal> rhythm) { static public List<Integer> embedSalahSequenceX18(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
return embedSalahSequence(new ArrayList<>(), type, arguments, false);
}
static public List<Integer> embedSalahSequenceX06(List<Integer> out, FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
return embedSalahSequence(out, type, arguments, true);
}
static public List<Integer> embedSalahSequenceX18(List<Integer> out, FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
return embedSalahSequence(out, type, arguments, false);
}
static private List<Integer> embedSalahSequence(List<Integer> out, FourCornerZion7SalahSequence type, List<List<Integer>> arguments, boolean isSixBit) {
Objects.requireNonNull(type);
Objects.requireNonNull(arguments);
if (FourCornerZion7SalahSequence.ESC_VT06.equals(type)) {
if (isSixBit) {
out.addAll(FCDotDEC2701DashPX0.ESC_VT06.baklavaPointSequence());
} else {
out.addAll(FCDotDEC2701DashPX0.ESC_VT06.cakePointSequence());
}
} else {
if (isSixBit) {
out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).baklavaPointSequence());
} else {
out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).cakePointSequence());
}
}
Iterator<List<Integer>> argu = arguments.iterator();
while (argu.hasNext()) {
List<Integer> arguValue = argu.next();
out.addAll(arguValue); // TODO: add range check
if (argu.hasNext()) {
out.add(FCDotCDC1604DashP6._RAKA_QUESTION.baklavaPointDotIndex());
}
}
out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.baklavaPointDotIndex());
return out;
}
static public List<Integer> embedSandWalkerX06(List<PrimordialOctal> rhythm) {
return embedSandWalkerX06(new ArrayList<>(), rhythm);
}
static public List<Integer> embedSandWalkerX06(List<Integer> out, List<PrimordialOctal> rhythm) {
Objects.requireNonNull(rhythm); Objects.requireNonNull(rhythm);
if (!FourCornerRecipe.SAND_WORM_SIGN.contains(rhythm.size())) { if (!FourCornerRecipe.SAND_WORM_SIGN.contains(rhythm.size())) {
throw new IllegalArgumentException("Sand walker rhythm is not 72 bit aligned: " + rhythm.size()); throw new IllegalArgumentException("Sand walker rhythm is not 72 bit aligned: " + rhythm.size());
@ -73,13 +119,12 @@ final public class FourCornerRecipe {
return out; return out;
} }
static public List<Integer> embedSandWorm(List<PrimordialOctal> spice) { static public List<Integer> embedSandWormX06(List<PrimordialOctal> spice) {
return embedSandWorm(new ArrayList<>(), spice); return embedSandWormX06(new ArrayList<>(), spice);
} }
static public List<Integer> embedSandWorm(List<Integer> out, List<PrimordialOctal> spice) { static public List<Integer> embedSandWormX06(List<Integer> out, List<PrimordialOctal> spice) {
Objects.requireNonNull(spice); Objects.requireNonNull(spice);
// TODO: redo for 18 bit FC this is 6 bit
out.add(FCDotDEC2701DashPX0.ESC68_SAND_WORM.cakePointDotIndex()); out.add(FCDotDEC2701DashPX0.ESC68_SAND_WORM.cakePointDotIndex());
for (int i = spice.size(); i >= 0; i--) { for (int i = spice.size(); i >= 0; i--) {
PrimordialOctal octal = spice.get(i); PrimordialOctal octal = spice.get(i);
@ -89,6 +134,15 @@ final public class FourCornerRecipe {
return out; return out;
} }
static public List<Integer> embedSandWormX18(List<PrimordialOctal> spice) {
return embedSandWormX18(new ArrayList<>(), spice);
}
static public List<Integer> embedSandWormX18(List<Integer> out, List<PrimordialOctal> spice) {
Objects.requireNonNull(spice);
return embedSandWormX06(out, spice); // TODO: write 18 bit version
}
static public List<Integer> embedNCR1632Denominator(BigInteger value) { static public List<Integer> embedNCR1632Denominator(BigInteger value) {
return embedNCR1632Value(new ArrayList<>(), value, FourCornerDotCake.FC_NCR1632_DEN.getStart()); return embedNCR1632Value(new ArrayList<>(), value, FourCornerDotCake.FC_NCR1632_DEN.getStart());
} }

View file

@ -24,7 +24,9 @@ package org.x4o.fc18;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -38,6 +40,7 @@ import org.x4o.fc18.cake2.pie9d.FCDotPIE9DDash09;
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
import org.x4o.fc18.octal8.PrimordialOctal; import org.x4o.fc18.octal8.PrimordialOctal;
import org.x4o.fc18.zion7.FourCornerZion7Candlelier; import org.x4o.fc18.zion7.FourCornerZion7Candlelier;
import org.x4o.fc18.zion7.FourCornerZion7SalahSequence;
import org.x4o.fc18.zion7.FourCornerZionStenoLexer; import org.x4o.fc18.zion7.FourCornerZionStenoLexer;
import org.x4o.fc18.zion7.FourCornerZionStenoLexerSmoke; import org.x4o.fc18.zion7.FourCornerZionStenoLexerSmoke;
@ -50,6 +53,7 @@ public class FourCornerUnicodeDisplay {
private boolean failPipeSmoke = false; private boolean failPipeSmoke = false;
private boolean handleEscape = true; private boolean handleEscape = true;
private String renderSeperator = null; private String renderSeperator = null;
private final Map<FourCornerZion7SalahSequence, Consumer<List<List<Integer>>>> escHandlers = new HashMap<>();
public FourCornerUnicodeDisplay(boolean failPipeSmoke, boolean handleEscape, String renderSeperator) { public FourCornerUnicodeDisplay(boolean failPipeSmoke, boolean handleEscape, String renderSeperator) {
this.failPipeSmoke = failPipeSmoke; this.failPipeSmoke = failPipeSmoke;
@ -57,10 +61,15 @@ public class FourCornerUnicodeDisplay {
this.renderSeperator = renderSeperator; this.renderSeperator = renderSeperator;
} }
public FourCornerUnicodeDisplay withEscapeHandler(FourCornerZion7SalahSequence type, Consumer<List<List<Integer>>> handler) {
escHandlers.put(type, handler);
return this;
}
static public FourCornerUnicodeDisplay text() { static public FourCornerUnicodeDisplay text() {
return new FourCornerUnicodeDisplay(false, true, null); return new FourCornerUnicodeDisplay(false, true, null);
} }
static public FourCornerUnicodeDisplay raw() { static public FourCornerUnicodeDisplay raw() {
return new FourCornerUnicodeDisplay(false, false, null); return new FourCornerUnicodeDisplay(false, false, null);
} }
@ -257,5 +266,13 @@ public class FourCornerUnicodeDisplay {
output.append("]"); output.append("]");
} }
} }
@Override
public void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
Consumer<List<List<Integer>>> handler = escHandlers.get(type);
if (handler != null) {
handler.accept(arguments);
}
}
} }
} }

View file

@ -45,31 +45,31 @@ public enum FCDotDEC2701DashPX0 implements FourCornerX06BaklavaPointSequence, Fo
// =========== External escape sequence, who MUST terminate with ! // =========== External escape sequence, who MUST terminate with !
/// _ESC6_X1 _ESC6_X1 _ESC6_X1 = 1 /// _ESC6_X1 _ESC6_X1 _ESC6_X1 = 1
_ESC_USER_1, ESC_USER_1,
/// _ESC6_X1 _ESC6_X1 _ESC6_X2 = 2 /// _ESC6_X1 _ESC6_X1 _ESC6_X2 = 2
_ESC_USER_2, ESC_USER_2,
/// _ESC6_X1 _ESC6_X1 _ESC6_X3 = 3 /// _ESC6_X1 _ESC6_X1 _ESC6_X3 = 3
_ESC_USER_3, ESC_USER_3,
/// _ESC6_X1 _ESC6_X2 _ESC6_X1 = 4 /// _ESC6_X1 _ESC6_X2 _ESC6_X1 = 4
_ESC_USER_4, ESC_USER_4,
/// _ESC6_X1 _ESC6_X2 _ESC6_X2 = 5 /// _ESC6_X1 _ESC6_X2 _ESC6_X2 = 5
_ESC_USER_5, ESC_USER_5,
/// _ESC6_X1 _ESC6_X2 _ESC6_X3 = 6 /// _ESC6_X1 _ESC6_X2 _ESC6_X3 = 6
_ESC_USER_6, ESC_USER_6,
/// _ESC6_X1 _ESC6_X3 _ESC6_X1 = 7 /// _ESC6_X1 _ESC6_X3 _ESC6_X1 = 7
_ESC_USER_7, __ESC_RESERVED_A7,
/// _ESC6_X1 _ESC6_X3 _ESC6_X2 = 8 /// _ESC6_X1 _ESC6_X3 _ESC6_X2 = 8
_ESC_USER_8, __ESC_RESERVED_A8,
/// _ESC6_X1 _ESC6_X3 _ESC6_X3 = 9 /// _ESC6_X1 _ESC6_X3 _ESC6_X3 = 9
_ESC_USER_9, __ESC_RESERVED_A9,
// =========== Internal escape sequence, to embed symbols,fractions and adult texts. // =========== Internal escape sequence, to embed symbols,fractions and adult texts.
@ -162,7 +162,7 @@ public enum FCDotDEC2701DashPX0 implements FourCornerX06BaklavaPointSequence, Fo
} }
public boolean isExternal() { public boolean isExternal() {
if (ordinal() <= _ESC_USER_9.ordinal()) { if (ordinal() <= ESC_USER_6.ordinal()) {
return true; return true;
} }
return false; return false;

View file

@ -48,6 +48,9 @@ public interface FourCornerZion7Candlelier {
/// Octal sand worm spice /// Octal sand worm spice
void strobeSandWorm(List<PrimordialOctal> spice); void strobeSandWorm(List<PrimordialOctal> spice);
/// Handles the lexer salah sequence strobes
void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments);
interface Adapter extends FourCornerZion7Candlelier { interface Adapter extends FourCornerZion7Candlelier {
@Override @Override
@ -69,5 +72,9 @@ public interface FourCornerZion7Candlelier {
@Override @Override
default void strobeSandWorm(List<PrimordialOctal> spice) { default void strobeSandWorm(List<PrimordialOctal> spice) {
} }
@Override
default void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
}
} }
} }

View file

@ -22,20 +22,18 @@
*/ */
package org.x4o.fc18.zion7; package org.x4o.fc18.zion7;
import java.util.List; /// The salah sequence strobe supported external types.
/// Handles the lexer salah sequence strobes.
/// ///
/// @author Willem Cazander /// @author Willem Cazander
/// @version 1.0 Jan 11, 2025 /// @version 1.0 Jan 11, 2025
public interface FourCornerZion7SalahSequence extends FourCornerZion7Candlelier { public enum FourCornerZion7SalahSequence {
void strobeSalahSequence(int type, List<List<Integer>> arguments); ESC_USER_1,
ESC_USER_2,
interface Adapter extends FourCornerZion7SalahSequence, FourCornerZion7Candlelier.Adapter { ESC_USER_3,
ESC_USER_4,
@Override ESC_USER_5,
default void strobeSalahSequence(int type, List<List<Integer>> arguments) { ESC_USER_6,
} ESC_VT06,
} ;
} }

View file

@ -27,7 +27,6 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import org.x4o.fc18.FourCornerRecipe; import org.x4o.fc18.FourCornerRecipe;
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
import org.x4o.fc18.octal8.PrimordialOctal; import org.x4o.fc18.octal8.PrimordialOctal;
/// Write steno for zion. /// Write steno for zion.
@ -44,7 +43,7 @@ public class FourCornerZionStenoGrapher {
return new FourCornerWriter(out, false); return new FourCornerWriter(out, false);
} }
static public final class FourCornerWriter implements FourCornerZion7AlphaOmega,FourCornerZion7SalahSequence,FourCornerZion7TempleScrolls { static public final class FourCornerWriter implements FourCornerZion7AlphaOmega,FourCornerZion7TempleScrolls {
private final List<Integer> out; private final List<Integer> out;
private final boolean isSixBit; private final boolean isSixBit;
@ -71,8 +70,9 @@ public class FourCornerZionStenoGrapher {
@Override @Override
public void strobeWords(List<Integer> cakePoints) { public void strobeWords(List<Integer> cakePoints) {
for (Integer cakePoint : cakePoints) { // todo: remove iterator int cakeSize = cakePoints.size();
strobeWord(cakePoint); for (int i = 0; i < cakeSize; i++) {
strobeWord(cakePoints.get(i));
} }
} }
@ -84,17 +84,25 @@ public class FourCornerZionStenoGrapher {
@Override @Override
public void strobeSandWalker(List<PrimordialOctal> rhythm) { public void strobeSandWalker(List<PrimordialOctal> rhythm) {
FourCornerRecipe.embedSandWalker(out, rhythm); FourCornerRecipe.embedSandWalkerX06(out, rhythm);
} }
@Override @Override
public void strobeSandWorm(List<PrimordialOctal> spice) { public void strobeSandWorm(List<PrimordialOctal> spice) {
FourCornerRecipe.embedSandWorm(out, spice); if (isSixBit) {
FourCornerRecipe.embedSandWormX06(out, spice);
} else {
FourCornerRecipe.embedSandWormX18(out, spice);
}
} }
@Override @Override
public void strobeSalahSequence(int type, List<List<Integer>> arguments) { public void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments) {
FCDotDEC2701DashPX0 cdcDECMode = FCDotDEC2701DashPX0.valueOf(type); if (isSixBit) {
FourCornerRecipe.embedSalahSequenceX06(out, type, arguments);
} else {
FourCornerRecipe.embedSalahSequenceX18(out, type, arguments);
}
} }
} }

View file

@ -51,12 +51,10 @@ public class FourCornerZionStenoLexer {
private final static FourCornerZion7AlphaOmega CLEAN_BIBLE = new FourCornerZion7AlphaOmega.Adapter() {}; private final static FourCornerZion7AlphaOmega CLEAN_BIBLE = new FourCornerZion7AlphaOmega.Adapter() {};
private final static FourCornerZionStenoLexerFire CLEAN_FIRE = new FourCornerZionStenoLexerFire.Adapter() {}; private final static FourCornerZionStenoLexerFire CLEAN_FIRE = new FourCornerZionStenoLexerFire.Adapter() {};
private final static FourCornerZionStenoLexerSmoke CLEAN_SMOKE = new FourCornerZionStenoLexerSmoke.Adapter() {}; private final static FourCornerZionStenoLexerSmoke CLEAN_SMOKE = new FourCornerZionStenoLexerSmoke.Adapter() {};
private final static FourCornerZion7SalahSequence CLEAN_PRAYER = new FourCornerZion7SalahSequence.Adapter() {};
private final static List<StenoScanner> CAKE_SLICE_EATERS = new ArrayList<>(); private final static List<StenoScanner> CAKE_SLICE_EATERS = new ArrayList<>();
private final boolean handlerEscape; private final boolean handlerEscape;
private final FourCornerZion7Candlelier handler; private final FourCornerZion7Candlelier handler;
private final FourCornerZion7AlphaOmega handlerDocument; private final FourCornerZion7AlphaOmega handlerDocument;
private final FourCornerZion7SalahSequence handlerSalahSequence;
private final FourCornerZion7TempleScrolls handlerTempleScrolls; private final FourCornerZion7TempleScrolls handlerTempleScrolls;
private final int denominatorBank[] = new int[64]; // <== is the terminator select are 6 bit of banks with 9 bit of values. private final int denominatorBank[] = new int[64]; // <== is the terminator select are 6 bit of banks with 9 bit of values.
private final int numeratorBank[] = new int[denominatorBank.length]; private final int numeratorBank[] = new int[denominatorBank.length];
@ -115,11 +113,6 @@ public class FourCornerZionStenoLexer {
} else { } else {
this.handlerDocument = CLEAN_BIBLE; this.handlerDocument = CLEAN_BIBLE;
} }
if (handler instanceof FourCornerZion7SalahSequence) {
this.handlerSalahSequence = FourCornerZion7SalahSequence.class.cast(handler);
} else {
this.handlerSalahSequence = CLEAN_PRAYER;
}
if (handler instanceof FourCornerZion7TempleScrolls) { if (handler instanceof FourCornerZion7TempleScrolls) {
this.handlerTempleScrolls = FourCornerZion7TempleScrolls.class.cast(handler); this.handlerTempleScrolls = FourCornerZion7TempleScrolls.class.cast(handler);
} else { } else {
@ -501,7 +494,11 @@ public class FourCornerZionStenoLexer {
if (readOK == false) { if (readOK == false) {
return true; // point is eaten return true; // point is eaten
} }
lexer.handlerSalahSequence.strobeSalahSequence(cdcDECMode.ordinal(), args); if (FCDotDEC2701DashPX0.ESC_VT06.equals(cdcDECMode)) {
lexer.handler.strobeSalahSequence(FourCornerZion7SalahSequence.ESC_VT06, args);
} else {
lexer.handler.strobeSalahSequence(FourCornerZion7SalahSequence.values()[cdcDECMode.ordinal()], args); // todo: use fast enum
}
return true; return true;
} }
if (FCDotDEC2701DashPX0.ESC68_2PIE9C.equals(cdcDECMode)) { if (FCDotDEC2701DashPX0.ESC68_2PIE9C.equals(cdcDECMode)) {

View file

@ -44,7 +44,7 @@ public class FCDotDEC0127DashPX0Test {
@Test @Test
public void testBaklavaSequence() throws Exception { public void testBaklavaSequence() throws Exception {
List<Integer> seq = null; List<Integer> seq = null;
seq = FCDotDEC2701DashPX0._ESC_USER_1.baklavaPointSequence(); seq = FCDotDEC2701DashPX0.ESC_USER_1.baklavaPointSequence();
Assertions.assertEquals(3, seq.size()); Assertions.assertEquals(3, seq.size());
Assertions.assertEquals(FCDotCDC1604DashP6._ESC6_X1.ordinal(), seq.get(0)); Assertions.assertEquals(FCDotCDC1604DashP6._ESC6_X1.ordinal(), seq.get(0));
Assertions.assertEquals(FCDotCDC1604DashP6._ESC6_X1.ordinal(), seq.get(1)); Assertions.assertEquals(FCDotCDC1604DashP6._ESC6_X1.ordinal(), seq.get(1));