Moved escaked point handling out of the lexer

This commit is contained in:
Willem Cazander 2025-01-16 23:33:01 +01:00
parent 547ad93953
commit 0d54b152dc
5 changed files with 41 additions and 59 deletions

View file

@ -244,6 +244,12 @@ public class FourCornerUnicodeDisplay {
codePoints.forEach(v -> output.appendCodePoint(v));
}
@Override
public void strobeRecursiveCake(List<Integer> cakePoints) {
FourCornerZionStenoLexer thisDisplayEscaked = new FourCornerZionStenoLexer(this, true);
thisDisplayEscaked.read(cakePoints);
}
@Override
public void strobeNether(List<Integer> key, List<Integer> octals) {
// TODO Auto-generated method stub
@ -260,10 +266,5 @@ public class FourCornerUnicodeDisplay {
output.append(";");
}
}
@Override
public void burnRecursive(int line, int col) {
throw new IllegalStateException("loop");
}
}
}

View file

@ -41,6 +41,8 @@ public interface FourCornerZion7Candlelier {
void strobeUnicode(List<Integer> codePoints);
void strobeRecursiveCake(List<Integer> cakePoints);
void strobeNether(List<Integer> key, List<Integer> octals);
interface Adapter extends FourCornerZion7Candlelier {
@ -57,6 +59,10 @@ public interface FourCornerZion7Candlelier {
default void strobeUnicode(List<Integer> codePoints) {
}
@Override
default void strobeRecursiveCake(List<Integer> cakePoints) {
}
@Override
default void strobeNether(List<Integer> key, List<Integer> octals) {
}

View file

@ -51,7 +51,6 @@ public class FourCornerZionStenoLexer {
private final int numeratorBank[] = new int[denominatorBank.length];
private List<Integer> input;
private int inputIndex = 0;
private int readLevel = 0;
private int currLine = 0;
private int currCol = 0;
private FourCornerZionStenoLexerSmoke smokeSignals = CLEAN_SMOKE;
@ -137,17 +136,10 @@ public class FourCornerZionStenoLexer {
public void read(List<Integer> points) {
input = Objects.requireNonNull(points);
readLevel++; // first puts on one, we allow level deep
if (readLevel > 2) {
smokeSignals.burnRecursive(currLine, currCol);
return;
}
if (readLevel == 1) {
inputIndex = 0;
currLine = 0;
currCol = 0; // allow reuse of lexer
handlerDocument.strobeDocumentAlpha();
}
while (true) {
ScanResult run = ScanResult.DONE;
while (run.isDone()) {
@ -164,11 +156,8 @@ public class FourCornerZionStenoLexer {
smokeSignals.burnUnsupported(currLine, currCol, input.get(inputIndex));
}
}
if (readLevel == 1) {
handlerDocument.strobeDocumentOmega();
}
readLevel--;
}
private ScanResult readTokens() {
ScanResult result = ScanResult.NEXT;
@ -247,7 +236,6 @@ public class FourCornerZionStenoLexer {
ScanResult result = ScanResult.DONE;
int idxFirst = lexer.inputIndex;
int idxLast = lexer.inputIndex;
while (true) {
int cakePoint = lexer.input.get(lexer.inputIndex);
if (cakePoint < blockStart || cakePoint > blockStop) {
@ -590,7 +578,9 @@ public class FourCornerZionStenoLexer {
if (FCDotDEC0127DashPX0.ESC68_FC18.equals(decMode)) {
List<List<Integer>> result = new ArrayList<>();
scanSalahRakaAt(lexer, result);
if (!result.isEmpty()) {
if (result.isEmpty()) {
return false;
}
List<Integer> renderCakePoints = new ArrayList<>();
for (List<Integer> argu : result) {
int cakePointArgu = 0;
@ -612,11 +602,9 @@ public class FourCornerZionStenoLexer {
}
}
}
FourCornerZionStenoLexer lexer2 = new FourCornerZionStenoLexer(lexer.handler);
lexer2.read(renderCakePoints);
lexer.handler.strobeRecursiveCake(renderCakePoints);
return true;
}
}
return false;
}

View file

@ -32,8 +32,6 @@ public interface FourCornerZionStenoLexerSmoke {
void burnUnsupported(int line, int col, int cakePoint);
void burnRecursive(int line, int col);
void burnInvalidEscape(int line, int col, int cakePoint);
@ -55,10 +53,6 @@ public interface FourCornerZionStenoLexerSmoke {
default void burnUnsupported(int line, int col, int cakePoint) {
}
@Override
default void burnRecursive(int line, int col) {
}
@Override
default void burnSalahInvalidCakePoint(int line, int col, int cakePoint) {
}

View file

@ -32,7 +32,6 @@ public class TestSmokeReader implements FourCornerZionStenoLexerSmoke.Adapter {
int errorUNI21UnusedBigIndian;
int errorUnsupport;
int errorRecursive;
public TestSmokeReader() {
reset();
@ -41,7 +40,6 @@ public class TestSmokeReader implements FourCornerZionStenoLexerSmoke.Adapter {
public void reset() {
errorUNI21UnusedBigIndian = -1;
errorUnsupport = -1;
errorRecursive = -1;
}
@Override
@ -53,9 +51,4 @@ public class TestSmokeReader implements FourCornerZionStenoLexerSmoke.Adapter {
public void burnUnsupported(int line, int col, int cakePoint) {
errorUnsupport = line;
}
@Override
public void burnRecursive(int line, int col) {
errorRecursive = line;
}
}