Parsing Operation
ParsingOperation describes the operations available for parsing Avail message names.
Author
Todd L Smith
Mark van Gulik
Parameters
The modulus that represents the operation uniquely for its arity.
Whether a PARSE_PART or PARSE_PART_CASE_INSENSITIVELY instructions can be moved safely leftward over this instruction.
Whether this instruction can be run if the first argument has been parsed but not yet consumed by a PARSE_ARGUMENT instruction.
Entries
16*N+15 - Reverse the N top elements of the stack. The new stack has the same depth as the old stack.
16*N+14 - Push a literal phrase containing the constant found at the position in the type list indicated by the operand.
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.
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.
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.
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.
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.
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).
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.
16*N+6 - Pop an argument from the parse stack and apply the conversion rule specified by N.
16*N+5 - Apply grammatical restrictions to the Nth leaf argument (underscore/ellipsis) of the current message, which is on the stack.
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.
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.
16*N+2 - Jump to instruction N, which must be before the current instruction. Attempt to continue parsing only at instruction N.
16*N+1 - Jump to instruction N, which must be after the current instruction. Attempt to continue parsing only at instruction N.
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.
15 - Reserved for future use.
14 - Reserved for future use.
13 - Reserved for future use.
12 - Concatenate the two lists that have been pushed previously.
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.
8 - Parse an argument of a message send, using the outermost (module) scope. Leave it on the parse stack.
7 - Parse a raw token. It should correspond to a variable that is in scope. Push a variable reference onto the parse stack.
6 - Parse an expression, even one whose expressionType is ⊤, then push a literal phrase wrapping this expression onto the parse stack.
5 - Parse an ordinary argument of a message send, pushing the expression onto the parse stack.
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.
3 - Pop the top marker off the mark stack.
2 - Push the current parse position onto the mark stack.
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.
0 - Push a new list that contains an empty tuple of phrases onto the parse stack.
Types
Functions
Assume that the instruction encodes an operand that represents the index of an argument to be checked (for grammatical restrictions): answer the operand.
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.
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.
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.
Extract the index of the type check argument for a TYPE_CHECK_ARGUMENT parsing instruction. This indexes the static MessageSplitter.constantForIndex.
Properties
Whether this instance commutes with PARSE_PART instructions.
A Statistic that records the number of nanoseconds spent while expanding occurrences of this ParsingOperation.
A Statistic that records the number of nanoseconds spent while executing occurrences of this ParsingOperation.