Skip to content

Parse two word directed commands - #86

Merged
punk-kaos merged 1 commit into
JS8Call-improved:masterfrom
tekstrand:directed-command-vocabulary
Aug 30, 2026
Merged

Parse two word directed commands#86
punk-kaos merged 1 commit into
JS8Call-improved:masterfrom
tekstrand:directed-command-vocabulary

Conversation

@tekstrand

Copy link
Copy Markdown
Contributor

What

  1. Parses two word directed commands like MSG TO: and QUERY MSGS whole instead of stopping at the first word
  2. Adds Js8Commands, a Kotlin copy of the kDirectedCmds table in varicode.cpp, to do the matching. Longest name first, and unknown text falls back to the old single token shape
  3. Removes the MSG inline-payload extraction and matches the branch on the two commands it handles
  4. Adds a unit test that reads kDirectedCmds out of varicode.cpp and fails when the Kotlin table drifts from it

Why

The store and forward work I have planned builds on this.

  1. The parser took the command as one whitespace token, so MSG TO: arrived as MSG with the destination glued to the payload, and QUERY MSGS arrived as QUERY.
  2. kDirectedCmds is the table the C++ side packs and unpacks against, but the unit tests run on the host JVM where the native library can't load, so the parser needs its own copy. Freetext comes through the same parser, so text that is not a command has to come out exactly as it did before.
  3. The extraction handled a command token with the payload stuck to it, like MSGHELLO. That shape can't reach the parser: directed frames unpack their command from the table by index and the JNI joins the parts with explicit spaces. It was dead code until now, but MSG TO: parsing whole would have set it off and put a stray TO: in the message text.
  4. Copies drift. The test parses varicode.cpp at test time, so a divergence fails the build instead of becoming a wire format bug.

Test

  1. ./gradlew :app:testDebugUnitTest (20 tests, 8 of them new, all passing)
  2. To watch the drift guard work, rename any command in kDirectedCmds in varicode.cpp and rerun. kotlinTableMatchesNativeVaricodeTable fails and prints the disagreement.

…he parser took the command as a single whitespace token, so MSG TO: arrived as MSG with the destination glued to the payload, and QUERY MSGS arrived as QUERY. The new Js8Commands table mirrors kDirectedCmds from the native varicode source and matches longest name first, so the two-word names parse whole. Unrecognized text falls back to the old single-token shape, so free-text frames reach callers unchanged. A unit test reads the native table out of varicode.cpp and fails when the Kotlin copy drifts from it.

Removed the MSG handler's inline-payload extraction rather than teaching it about MSG TO:. It existed to handle a command token with the payload stuck to it, a shape the engine cannot produce: a directed frame unpacks its command from the table by index, and the JNI joins the parts with explicit separators. It was dead code until now, but MSG TO: parsing as a whole command would have set it off and put a stray TO: into the delivered text. The MSG branch now matches the two commands it actually handles.
@punk-kaos
punk-kaos merged commit b15c650 into JS8Call-improved:master Aug 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants