ParsingOperation

enum ParsingOperation : Enum<ParsingOperation>

ParsingOperation describes the operations available for parsing Avail message names.

Author

Todd L Smith

Mark van Gulik

Parameters

modulus

The modulus that represents the operation uniquely for its arity.

commutesWithParsePart

Whether a PARSE_PART or PARSE_PART_CASE_INSENSITIVELY instructions can be moved safely leftward over this instruction.

canRunIfHasFirstArgument

Whether this instruction can be run if the first argument has been parsed but not yet consumed by a PARSE_ARGUMENT instruction.

Entries

Link copied to clipboard
REVERSE_STACK(15, true, true)

16*N+15 - Reverse the N top elements of the stack. The new stack has the same depth as the old stack.

Link copied to clipboard
PUSH_LITERAL(14, true, true)

16*N+14 - Push a literal phrase containing the constant found at the position in the type list indicated by the operand.

Link copied to clipboard
WRAP_IN_LIST(13, true, true)

16*N+13 - Pop N arguments from the parse stack of the current potential message send. Create an N-element list with them, and push the list back onto the parse stack.

Link copied to clipboard
TYPE_CHECK_ARGUMENT(12, true, true)

16*N+12 - Use the type of the argument just parsed to select among successor message bundle trees. Those message bundle trees are filtered by the allowable leaf argument type. This test is precise, and requires repeated groups to be unrolled for the tuple type specific to that argument slot of that definition, or at least until the A_Type.defaultType of the tuple type has been reached.

Link copied to clipboard
CHECK_AT_MOST(11, true, true)

16*N+11 - Check that the list phrase on the top of the stack has at most the specified size. Proceed to the next instruction only if this is the case.

Link copied to clipboard
CHECK_AT_LEAST(10, true, true)

16*N+10 - Check that the list phrase on the top of the stack has at least the specified size. Proceed to the next instruction only if this is the case.

Link copied to clipboard
PERMUTE_LIST(9, true, true)

16*N+9 - Permute the elements of the list phrase on the top of the stack via the permutation found via MessageSplitter.permutationAtIndex. The list phrase must be the same size as the permutation.

Link copied to clipboard
RUN_PREFIX_FUNCTION(8, false, true)

16*N+8 - A macro has been parsed up to a section checkpoint (§), and a copy of the cleaned up parse stack has been pushed, so invoke the Nth prefix function associated with the macro. Consume the previously pushed copy of the parse stack. The current ParserState's ParserState.clientDataMap is stashed in the new fiber's globals map and retrieved afterward, so the prefix function and macros can alter the scope or communicate with each other by manipulating this map. This technique prevents chatter between separate fibers (i.e., parsing can still be done in parallel) and between separate linguistic abstractions (the keys are atoms and are therefore modular).

Link copied to clipboard

16*N+7 - A macro has been parsed up to a section checkpoint (§). Make a copy of the parse stack, then perform the equivalent of an APPEND_ARGUMENT on the copy, the specified number of times minus one (because zero is not a legal operand). Make it into a single list phrase and push it onto the original parse stack. It will be consumed by a subsequent RUN_PREFIX_FUNCTION.

Link copied to clipboard
CONVERT(6, true, true)

16*N+6 - Pop an argument from the parse stack and apply the conversion rule specified by N.

Link copied to clipboard
CHECK_ARGUMENT(5, true, true)

16*N+5 - Apply grammatical restrictions to the Nth leaf argument (underscore/ellipsis) of the current message, which is on the stack.

Link copied to clipboard

16*N+4 - Parse the Nthmessage part of the current message. This will be a specific token. It should be matched case insensitively against the source token.

Link copied to clipboard
PARSE_PART(3, false, false)

16*N+3 - Parse the Nthmessage part of the current message. This will be a specific token. It should be matched case sensitively against the source token.

Link copied to clipboard
JUMP_BACKWARD(2, false, true)

16*N+2 - Jump to instruction N, which must be before the current instruction. Attempt to continue parsing only at instruction N.

Link copied to clipboard
JUMP_FORWARD(1, false, true)

16*N+1 - Jump to instruction N, which must be after the current instruction. Attempt to continue parsing only at instruction N.

Link copied to clipboard
BRANCH_FORWARD(0, false, true)

16*N+0 - Branch to instruction N, which must be after the current instruction. Attempt to continue parsing at both the next instruction and instruction N.

Link copied to clipboard
RESERVED_15(15, false, true)

15 - Reserved for future use.

Link copied to clipboard
RESERVED_14(14, false, true)

14 - Reserved for future use.

Link copied to clipboard
RESERVED_13(13, false, true)

13 - Reserved for future use.

Link copied to clipboard
CONCATENATE(12, false, true)

12 - Concatenate the two lists that have been pushed previously.

Link copied to clipboard
PARSE_RAW_LITERAL_TOKEN(11, false, false)

11 - Parse a raw literaltoken, leaving it on the parse stack.

Link copied to clipboard
PARSE_RAW_KEYWORD_TOKEN(10, false, false)

10 - Parse a raw keywordtoken, leaving it on the parse stack.

Link copied to clipboard
PARSE_ANY_RAW_TOKEN(9, false, false)

9 - Parse anyraw token, leaving it on the parse stack. In particular, push a literal phrase whose token is a synthetic literal token whose value is the actual token that was parsed.

Link copied to clipboard

8 - Parse an argument of a message send, using the outermost (module) scope. Leave it on the parse stack.

Link copied to clipboard
PARSE_VARIABLE_REFERENCE(7, false, true)

7 - Parse a raw token. It should correspond to a variable that is in scope. Push a variable reference onto the parse stack.

Link copied to clipboard

6 - Parse an expression, even one whose expressionType is ⊤, then push a literal phrase wrapping this expression onto the parse stack.

Link copied to clipboard
PARSE_ARGUMENT(5, false, true)

5 - Parse an ordinary argument of a message send, pushing the expression onto the parse stack.

Link copied to clipboard
ENSURE_PARSE_PROGRESS(4, false, true)

4 - Pop the top marker off the mark stack and compare it to the current parse position. If they're the same, abort the current parse, otherwise push the current parse position onto the mark stack in place of the old marker and continue parsing.

Link copied to clipboard

3 - Pop the top marker off the mark stack.

Link copied to clipboard
SAVE_PARSE_POSITION(2, false, true)

2 - Push the current parse position onto the mark stack.

Link copied to clipboard
APPEND_ARGUMENT(1, true, true)

1 - Pop an argument from the parse stack of the current potential message send. Pop a list from the parse stack. Append the argument to the list. Push the resultant list onto the parse stack.

Link copied to clipboard
EMPTY_LIST(0, true, true)

0 - Push a new list that contains an empty tuple of phrases onto the parse stack.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open fun checkArgumentIndex(instruction: Int): Int

Assume that the instruction encodes an operand that represents the index of an argument to be checked (for grammatical restrictions): answer the operand.

Link copied to clipboard
open fun describe(operand: Int): String

Describe the operation for the debugger, using the supplied operand.

Link copied to clipboard
fun encoding(operand: Int): Int

Answer the instruction coding of the receiver for the given operand. The receiver must be arity one (1), which is equivalent to its ordinal being greater than or equal to distinctInstructions.

Link copied to clipboard
open fun keywordIndex(instruction: Int): Int

Assume that the instruction encodes an operand that represents a message part index: answer the operand. Answer 0 if the operand does not represent a message part.

Link copied to clipboard
open fun successorPcs(instruction: Int, currentPc: Int): List<Int>

Given an instruction and program counter, answer the list of successor program counters that should be explored. For example, a BRANCH_FORWARD instruction will need to visit both the next program counter and the branch target.

Link copied to clipboard
open fun typeCheckArgumentIndex(instruction: Int): Int

Extract the index of the type check argument for a TYPE_CHECK_ARGUMENT parsing instruction. This indexes the static MessageSplitter.constantForIndex.

Properties

Link copied to clipboard
val canRunIfHasFirstArgument: Boolean

Whether this operation can run successfully if there is a pre-parsed first argument that has not yet been consumed.

Link copied to clipboard
val commutesWithParsePart: Boolean

Whether this instance commutes with PARSE_PART instructions.

Link copied to clipboard
val encoding: Int

The instruction coding of the receiver.

Link copied to clipboard
val expandingStatisticInNanoseconds: Statistic

A Statistic that records the number of nanoseconds spent while expanding occurrences of this ParsingOperation.

Link copied to clipboard
val name: String
Link copied to clipboard
val ordinal: Int
Link copied to clipboard
val parsingStatisticInNanoseconds: Statistic

A Statistic that records the number of nanoseconds spent while executing occurrences of this ParsingOperation.