PhraseNode

class PhraseNode(val atomModuleName: A_String?, val atomName: A_String?, val usageType: NamesIndex.UsageType, val tokenSpans: List<PhrasePathRecord.PhraseNode.PhraseNodeToken>, var parent: PhrasePathRecord.PhraseNode?, val children: MutableList<PhrasePathRecord.PhraseNode> = mutableListOf())

A node of a tree that represents an occurrence of an A_Phrase in this A_Module. If the phrase is a send or macro invocation, the information about which atom's bundle was sent is available, as are the tokens that are part of the phrase (but not its subphrases).

Constructors

Link copied to clipboard
constructor(atomModuleName: A_String?, atomName: A_String?, usageType: NamesIndex.UsageType, tokenSpans: List<PhrasePathRecord.PhraseNode.PhraseNodeToken>, parent: PhrasePathRecord.PhraseNode?, children: MutableList<PhrasePathRecord.PhraseNode> = mutableListOf())

Create a PhraseNode from its parts. The list of children is mutable, and can be provided here or added later.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class PhraseNodeToken(val start: Int, val pastEnd: Int, val line: Int, val tokenIndexInName: Int, val tokenContent: String?)

An entry in the tokenSpans of a PhraseNode. The start and pastEnd identify where the token occurs in the UCS-2 source String, using zero-based indices. The tokenIndexInName is either zero or a one-based index into the atom's MessageSplitter's MessageSplitter.messageParts, indicating the part of the message that this token matched during parsing.

Properties

Link copied to clipboard

If this node is a SEND_PHRASE or MACRO_SUBSTITUTION_PHRASE, this is the name of the module in which the sent bundle's atom was defined. Otherwise null.

Link copied to clipboard

If this node is a SEND_PHRASE or MACRO_SUBSTITUTION_PHRASE, this is the name of the sent bundle's atom. Otherwise null.

Link copied to clipboard

The children of this phrase, which roughly correspond to subphrases. For a send phrase or macro send phrase, these may be the argument phrases or the list phrases that group them, depending on the structure of the sent bundle's name (see MessageSplitter).

Link copied to clipboard

This is the 1-based index of this node within its parent, or -1 if there is no parent.

Link copied to clipboard

As a nicety, a PhraseNode can answer the optional NameInModule that represents the name of what's being called, if anything.

Link copied to clipboard

The node representing the optional parent phrase of this node's phrase. This can be provided here, or left null to be set later. If present, the new node will be automatically added as a child of the parent.

Link copied to clipboard

If the atomName is not null, this is a lazily-computed MessageSplitter derived from that name. Otherwise, this is null.

Link copied to clipboard

The regions of the file that tokens of this phrase occupy. Each region is a PhraseNodeToken representing the one-based start and pastEnd positions in the source string, adjusted to UCS-2 ("Char") positions. It also contains an index into the splitter's tuple of parts, to say what the token was, or zero if it was not a literal part of the message name.

Link copied to clipboard

The UsageType that indicates the nature of the phrase that this node summarizes.

Functions

Link copied to clipboard
fun depth(): Int
Link copied to clipboard
fun describeOn(builder: StringBuilder, characterBudget: Int)

Output this phrase on the builder, while trying to avoid exceeding the characterBudget. The builder expects html text, but without the outer html tag.

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