Skip to content

This site describes solve-engine 2.44.0, the version npm installs.

PhraseSlot

type PhraseSlot =
| {
kind: "keyword";
tokenTypes: string[];
}
| {
bindingPower?: number;
kind: "expr";
};

Defined in: packages/engine/src/parser/PhrasePattern.ts:33

A single slot in a phrase-grammar alternative.

  • keyword: consumes exactly one token whose type is in tokenTypes. Its matched token is recorded in the captures array passed to emit() (in slot order). This is how an alternative distinguishes “between X and Y” from “from X to Y” if it needs to.
  • expr: parses a full sub-expression via parser.parseExpression(). Its bytecode is emitted inline, in slot order, exactly like a hand-written parselet calling parseExpression() directly. Not recorded in captures (there’s no single token to record).