Generation/Parsing Rules for Message Encapsulation
The rules for forwarding/bursting are described in terms of regular expressions. The first author originally derived simple finite-state automata for the rules, but was unable to legibly represent them in this memo. It is suggested that the implementors sketch the automata to understand the grammar.
The conventions used for the grammar are simple. Each state is followed by one or more alternatives, which are separated by the "|" character. Each alternative starts with a character that is received as input. (CRLF, although two characters is treated as one character herein.) The last alternative for a state is the character "c", which represents any character not specified in the preceeding alternatives. Optionally following the input character is an output string enclosed by curly-braces. Following this is the state that the automata enters. The reader should note that these grammars are extremely simple to implement (and, in most cases, can be implemented quite efficiently).
When the forwarding agent encapsulates a message, it should apply the following finite-state automaton. The initial state is S1.
S1 :: CRLF {CRLF} S1
| "-" {"- -"} S2
| c {c} S2
S2 :: CRLF {CRLF} S1
| c {c} S2
This simply says that anytime a "-" is found at the beginning of a line, a "- " is output prior to outputting the line.
When the bursting agent decapsulates the text portion of a draft, it should apply the following finite-state automaton. The initial state is S1.
S1 :: "-" S3
| CRLF {CRLF} S1
| c {c} S2
S2 :: CRLF {CRLF} S1
| c {c} S2
S3 :: " " S2
| c S4
S4 :: CRLF S5
| c S4
S5 :: CRLF S5
| c {c} S2
Although more complicated than the grammar used by the forwarding agent to encapsulate a single message, this grammer is still quite simple. Let us make the simplifying assumption that both the initial and final text sections of the draft are messages in addition to the encapsulated messages.
To begin, the current message being burst is scanned at state S1. All characters are output until the EB is found (state S3). If "- " is found, the automaton enters state S2 and characters from the current message are continued to be output. Finally, a true EB is found (state S4). As the automaton traverses from state S3 to S4, the bursting agent should consider the current message ended. The remainder of the EB is discarded (states S4 and S5). As the automaton traverses from state S5 to S2, the bursting agent should consider a new message started and output the first character. In state S2, all characters are output until the EB is found.