PhraseNode

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

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
fun PhraseNode(    atomModuleName: A_String?,     atomName: A_String?,     tokenSpans: List<Repository.PhraseNode.PhraseNodeToken>,     children: MutableList<Repository.PhraseNode> = mutableListOf(),     parent: Repository.PhraseNode?)

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 tokenIndexInName: Int)

An entry in the tokenSpans of a PhraseNode. The start and pastEnd identify where the token occurs in the UCS-2 source String, but using one-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.

Functions

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

Properties

Link copied to clipboard
val atomModuleName: A_String?

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
val atomName: A_String?

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
val children: MutableList<Repository.PhraseNode>

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
var indexInParent: Int

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

Link copied to clipboard
var parent: Repository.PhraseNode?

The node representing the optional parent phrase of this node's phrase. This can be provided here, or left null to be set later.

Link copied to clipboard
var splitter: MessageSplitter? = null

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

Link copied to clipboard
val tokenSpans: List<Repository.PhraseNode.PhraseNodeToken>

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.