MessageSplitter

MessageSplitter is used to split Avail message names into a sequence of instructions that can be used directly for parsing.

Message splitting occurs in two phases. In the first setPhase, the message is tokenized and parsed into an abstract Expression tree. In the second setPhase, a tuple type of phrase types is supplied, and produces a tuple of integer-encoded ParsingOperations.

Author

Mark van Gulik

Todd L Smith

Parameters

messageName

An Avail string specifying the keywords and arguments of some message being defined.

Throws

If the message name is malformed.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

The metacharacters used in message names.

Properties

Link copied to clipboard

The computed list of Simple expressions recursively inside the rootSequence.

Link copied to clipboard

Does the message contain any groups?

Link copied to clipboard

The number of underscores/ellipses present in the method name. This is not the same as the number of arguments that a method implementing this name would accept, as a top-level guillemet group with N recursively embedded underscores/ellipses is counted as N, not one.

Link copied to clipboard

The Avail string to be parsed. It must be SHARED.

Link copied to clipboard

The individual tokens (strings) constituting the message.

Link copied to clipboard

Return the number of arguments a MethodDefinitionDescriptor implementing this name would accept. Note that this is not necessarily the number of underscores and ellipses, as a guillemet group may contain zero or more underscores/ellipses (and other guillemet groups) but count as one top-level argument.

Link copied to clipboard

The number of SectionCheckpoints encountered so far.

Link copied to clipboard

Answer whether there are any reordered expressions anywhere inside this method name. Reordering is specified by placing circled numbers (e.g., ①, ②) after all argument-yielding Expressions occurring in some Sequence. Either none or all must be numbered within any sequence, and the numbers must be a non-identity permutation (not simply ①, ②, ③, etc.).

Functions

Link copied to clipboard
fun checkImplementationSignature(functionType: A_Type, sectionNumber: Int = Integer.MAX_VALUE)

Check that an implementation with the given signature is appropriate for a message like this.

Link copied to clipboard

Answer whether the given list is correctly internally structured for a send of this message. It must recursively match the expected number of arguments, as well as have the expected permutations in the corresponding recursive Expressions.

Link copied to clipboard
fun highlightedNameFor(phraseType: A_Type, pc: Int): String

Answer a String containing the message name with an indicator inserted to show which area of the message is being parsed by the given program counter.

Link copied to clipboard

Given a series of one-based indices that indicate how to traverse the nested lists of some call site to a single point of interest, follow the corresponding Expressions to identify the region of the name identified by that path.

Link copied to clipboard

Answer a tuple of Avail integers describing how to parse this message. See MessageSplitter and ParsingOperation for an understanding of the parse instructions.

Link copied to clipboard
fun printSendNodeOnIndent(sendPhrase: A_Phrase, builder: StringBuilder, indent: Int)

Pretty-print a send of this message with given argument phrases.

Link copied to clipboard
fun rangeToHighlightForPartIndex(messagePartIndex: Int): IntRange

Given a one-based messagePartIndex into this splitter's tokenized parts, answer the one-based (inclusive) range of the message covered by that message part.

Link copied to clipboard
open override fun toString(): String