Skip to content

Commit

Permalink
Fix Signal enumeration
Browse files Browse the repository at this point in the history
- Signal.X.ordinal() == Signal.X.signal()-Signal.NUL.signal()
  - X<NONE
- preset kernel matrix transitions to signal NUL everywhere all the time

Signed-off-by: jrte <jrte.project@gmail.com>
  • Loading branch information
jrte committed Sep 20, 2023
1 parent e663dac commit 9d894b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/com/characterforming/jrte/engine/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,10 @@ protected long[] readTransitionMatrix() throws ModelException {
matrix = new long[nStates * nInputs];
// preset all cells to signal NUL without changing state
for (int state = 0; state < nStates; state++) {
final int toState = state * nInputs;
final long nul = Transducer.transition(toState, 0);
final int base = state * nInputs, toState = base;
final long nul = Transducer.transition(toState, Signal.NUL.ordinal());
for (int input = 0; input < nInputs; input++) {
matrix[toState + input] = nul;
matrix[base + input] = nul;
}
}
// fill in defined transitions
Expand Down
6 changes: 3 additions & 3 deletions src/com/characterforming/ribose/base/Signal.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
*
*/
public enum Signal {
/** Signals nothing, for optionality (use as null) */
NONE(new byte[] {}, -1),
/** Signals first chance to handle missing transition on current input symbol */
NUL(new byte[] { 'n', 'u', 'l' }, 256),
/** Signals anything, used as a generic out-of-band prompt to trigger actions */
NIL(new byte[] { 'n', 'i', 'l' }, 257),
/** Signals end of feature, used as a generic feature delimiter */
EOL(new byte[] { 'e', 'o', 'l' }, 258),
/** Signals end of transduction input */
EOS(new byte[] { 'e', 'o', 's' }, 259);
EOS(new byte[] { 'e', 'o', 's' }, 259),
/** Signals nothing, for optionality (use as null) */
NONE(new byte[] {}, -1);

private final Bytes sym;
private final Bytes ref;
Expand Down

0 comments on commit 9d894b3

Please sign in to comment.