Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

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).