The terse @id/- dialogue-text parsing engine behind both two-d/stage.parseDialogueText
and rpg.parseDialogueText - the two-speaker alternation state machine lives here once,
in core (already the home of parseCSV, another generic text-format parser that other
modules build their own typed result around), so a rule change or a bug fix lands in one
place instead of two silently-drifting copies. Each module's own wrapper only maps
DialogueLine onto its own command shape - StageCommand's as versus EventCommand's
speaker is the one real difference between them.
Three kinds of line:
@id text names who is speaking and says text; @id alone (no text) just registers
the speaker, without saying anything yet.
- text continues the two-speaker exchange the first two @id lines opened,
alternating speaker on every line: the first - after the two openers goes to
whichever of them did not speak last, and so on.
any other non-blank line narrates, with no speaker.
@aliceHello. @bobHi! - Howareyou? - Fine, andyou?
The - shorthand is deliberately capped at two speakers: it exists for the two-character
back-and-forth, not as a guess at which of three or more people talks next. A third
distinct @id anywhere in the source is a parse error rather than a silent guess.
The terse
@id/-dialogue-text parsing engine behind bothtwo-d/stage.parseDialogueTextandrpg.parseDialogueText- the two-speaker alternation state machine lives here once, incore(already the home ofparseCSV, another generic text-format parser that other modules build their own typed result around), so a rule change or a bug fix lands in one place instead of two silently-drifting copies. Each module's own wrapper only mapsDialogueLineonto its own command shape -StageCommand'sasversusEventCommand'sspeakeris the one real difference between them.Three kinds of line:
@id textnames who is speaking and saystext;@idalone (no text) just registers the speaker, without saying anything yet.- textcontinues the two-speaker exchange the first two@idlines opened, alternating speaker on every line: the first-after the two openers goes to whichever of them did not speak last, and so on.The
-shorthand is deliberately capped at two speakers: it exists for the two-character back-and-forth, not as a guess at which of three or more people talks next. A third distinct@idanywhere in the source is a parse error rather than a silent guess.Example