import { type MarkupElement } from "./markup.ts"; export type InlineKind = "word" | "literal" | "string" | "operator" | "open" | "close" | "comma" | "colon" | "dot" | "at" | "embedded" | "markup" | "comment"; export interface InlineToken { readonly kind: InlineKind; readonly text: string; readonly generic?: boolean; /** The parsed element behind a "markup" token; the printer owns its layout. */ readonly element?: MarkupElement; } export declare const multiCharacterOperators: readonly [">>>=", "<<=", ">>=", ">>>", "<<", ">>", "...", "?.", "??", "->", "=>", "==", "!=", "<=", ">=", "**", "+=", "-=", "*=", "/=", "%=", "|=", "&=", "^="]; export declare const binaryWords: Set; export declare const prefixWords: Set; export declare const statementHeadKeywordWords: Set; /** * The reserved words that stand in expression position: `super` and `import` * name one directly — `super(id)`, `import("./page.vel")` — and the formatter * has already read `true`, `false` and `null` as literals by the time this set * is consulted. Every other reserved word is a keyword in the structural sense * `endsExpression` uses: it cannot end an expression, so what follows it opens * a new one. */ export declare const expressionKeywordWords: Set; export declare const nonExpressionKeywordWords: Set; export declare function blockCommentEnd(source: string, start: number): number; export declare function lastLineWidth(output: string): number; /** * D57 rule 134, restated for this file: the spacing questions below are all one * question — does the token in front end an expression? What follows something * that ends one is applied to it (`values[0]` indexes, `f(x)` calls, `a - b` * subtracts, `a < b` compares); what follows anything else begins a fresh * expression (`const [head, ...tail]` destructures, `async (id) =>` takes * parameters, `return -1` negates, `?? x` is markup). * * The tokens that can end an expression are a closed structural set: a name, a * literal, a string, a closing bracket, an element. The words that cannot are * the language's own reserved vocabulary, read from the lexer's table rather * than kept here. The hand-kept list this replaced was blind to `const` and * `let` (D59 143.1), to `async` (143.2), and to `return` in front of an * operator (143.3), and a word the language gains tomorrow would have gone * missing from it the same way. */ export declare function endsExpression(token: InlineToken | undefined, statementHead?: boolean): boolean; /** * D60 rule 147: whether a `<` opens embedded markup is the same question. An * element stands where an expression can begin — after `??`, after `and`, after * a comma, at the head of a line — and a comparison stands after something that * ends an expression. Reading a list of the positions instead is what wrote * `{text ?? x}` out as `{text ?? < em > x < / em >}`, which no longer * compiles. */ export declare function beginsEmbeddedAngleSyntax(tokens: readonly InlineToken[], source: string, index: number): boolean; /** * D59 rule 142 — `name=value` is one argument, and the charter and every * documentation table spell it tight. Which `=` separates a named argument is a * question about position: the name has to open an argument (it follows the * call's `(`, or a `,` inside it) and the parentheses have to be a call's. The * other `=` that stands inside parentheses is a default value, and a default * value's parentheses belong to a declaration or a lambda, never to a call. */ export declare function isNamedArgumentEquals(tokens: readonly InlineToken[], index: number, preceding?: InlineToken, insideCallArguments?: boolean): boolean; /** * What an open bracket opened, for the lines inside it. A `(` that applies to * something that ends an expression and is not a declaration's parameter list * is a call's argument list, and a named argument is written tight inside one. */ export declare function openBracketRole(tokens: readonly InlineToken[], index: number): "call" | "other"; /** The index of the `(` whose argument list `index` sits directly inside. */ export declare function enclosingParenIndex(tokens: readonly InlineToken[], index: number): number; /** * A declaration's parentheses hold parameters, and a parameter's `= value` is a * default. Three positions say the list is a declaration's, and none of them * needs to know which words introduce a declaration: * * - `def name(...)`, with or without a type argument list of its own. * - Two names in a row in front of it. Nothing applies one name to another in * an expression, so `component Row(...)` and `action submit(...)` are * declaration headers while `check(...)` and `if check(...)` are calls — * including the declaration forms an extension owns, which this file cannot * otherwise see. * - A single name at the head of a line whose `)` opens a block, which is * `constructor(...):` and nothing a call can be. */ export declare function isDeclarationParameterList(tokens: readonly InlineToken[], open: number): boolean; export declare function matchingGenericOpenIndex(tokens: readonly InlineToken[], close: number): number; export declare function matchingCloseIndex(tokens: readonly InlineToken[], open: number): number; export declare function isAttachedOpaqueSourcePlaceholder(token: InlineToken): boolean; export declare function isUnaryOperator(token: InlineToken, previous: InlineToken | undefined, statementHead?: boolean): boolean; export declare function isOptionalQuestion(token: InlineToken, next: InlineToken | undefined, after: InlineToken | undefined): boolean; export declare function isTernaryColon(tokens: readonly InlineToken[], colonIndex: number): boolean; export declare function needsSpace(previous: InlineToken, current: InlineToken, next: InlineToken | undefined, tokens: readonly InlineToken[], index: number, preceding: InlineToken | undefined, insideCallArguments?: boolean): boolean; //# sourceMappingURL=tokens.d.ts.map