/** * Expressions in the source dialect, read by recursive descent. * * The precedence ladder is the source dialect's, and it is the same shape as * OpenScript's (`language.md` 9.1): the ternary lowest, then `or`, `and`, * equality, comparison, the additive and multiplicative operators, and the * unary operators with `not` among them. So a tree read here prints back into * OpenScript with parentheses only where the tree needs them, and never with a * different grouping. * * What the reader does not accept it reports by throwing `Unreadable` with the * place and a few words naming the form, and the statement reader turns that * into a statement kept whole. It is the one exception in the importer, and it * never leaves this module and the statement reader beside it. */ import type { Token } from './lexer.js'; import type { Expr, Place } from './syntax.js'; /** A form the reader does not accept, and where it starts. */ export declare class Unreadable extends Error { readonly at: Place; readonly construct: string; constructor(at: Place, construct: string); } /** The words the reader takes for a form it does not read, per bad token. */ export declare function badConstruct(token: Token): string; export declare const UNREAD = "a statement in a form its reader does not accept"; export declare class Cursor { index: number; readonly tokens: readonly Token[]; constructor(tokens: readonly Token[]); peek(ahead?: number): Token | undefined; /** Whether the next token is this operator or word. */ sees(text: string, ahead?: number): boolean; done(): boolean; take(): Token; expect(text: string): Token; /** Refuse at the next token, or at the end of the line when there is none. */ fail(): never; /** Zero width, just after the last token. */ endPlace(): Place; } export declare function placeOf(token: Token): Place; export declare function expression(c: Cursor): Expr; //# sourceMappingURL=expressions.d.ts.map