[d24f17c] | 1 | export { createScalarToken, resolveAsScalar, setScalarValue } from './cst-scalar.js';
|
---|
| 2 | export { stringify } from './cst-stringify.js';
|
---|
| 3 | export { visit, Visitor, VisitPath } from './cst-visit.js';
|
---|
| 4 | export interface SourceToken {
|
---|
| 5 | type: 'byte-order-mark' | 'doc-mode' | 'doc-start' | 'space' | 'comment' | 'newline' | 'directive-line' | 'anchor' | 'tag' | 'seq-item-ind' | 'explicit-key-ind' | 'map-value-ind' | 'flow-map-start' | 'flow-map-end' | 'flow-seq-start' | 'flow-seq-end' | 'flow-error-end' | 'comma' | 'block-scalar-header';
|
---|
| 6 | offset: number;
|
---|
| 7 | indent: number;
|
---|
| 8 | source: string;
|
---|
| 9 | }
|
---|
| 10 | export interface ErrorToken {
|
---|
| 11 | type: 'error';
|
---|
| 12 | offset: number;
|
---|
| 13 | source: string;
|
---|
| 14 | message: string;
|
---|
| 15 | }
|
---|
| 16 | export interface Directive {
|
---|
| 17 | type: 'directive';
|
---|
| 18 | offset: number;
|
---|
| 19 | source: string;
|
---|
| 20 | }
|
---|
| 21 | export interface Document {
|
---|
| 22 | type: 'document';
|
---|
| 23 | offset: number;
|
---|
| 24 | start: SourceToken[];
|
---|
| 25 | value?: Token;
|
---|
| 26 | end?: SourceToken[];
|
---|
| 27 | }
|
---|
| 28 | export interface DocumentEnd {
|
---|
| 29 | type: 'doc-end';
|
---|
| 30 | offset: number;
|
---|
| 31 | source: string;
|
---|
| 32 | end?: SourceToken[];
|
---|
| 33 | }
|
---|
| 34 | export interface FlowScalar {
|
---|
| 35 | type: 'alias' | 'scalar' | 'single-quoted-scalar' | 'double-quoted-scalar';
|
---|
| 36 | offset: number;
|
---|
| 37 | indent: number;
|
---|
| 38 | source: string;
|
---|
| 39 | end?: SourceToken[];
|
---|
| 40 | }
|
---|
| 41 | export interface BlockScalar {
|
---|
| 42 | type: 'block-scalar';
|
---|
| 43 | offset: number;
|
---|
| 44 | indent: number;
|
---|
| 45 | props: Token[];
|
---|
| 46 | source: string;
|
---|
| 47 | }
|
---|
| 48 | export interface BlockMap {
|
---|
| 49 | type: 'block-map';
|
---|
| 50 | offset: number;
|
---|
| 51 | indent: number;
|
---|
| 52 | items: Array<{
|
---|
| 53 | start: SourceToken[];
|
---|
| 54 | key?: never;
|
---|
| 55 | sep?: never;
|
---|
| 56 | value?: never;
|
---|
| 57 | } | {
|
---|
| 58 | start: SourceToken[];
|
---|
| 59 | key: Token | null;
|
---|
| 60 | sep: SourceToken[];
|
---|
| 61 | value?: Token;
|
---|
| 62 | }>;
|
---|
| 63 | }
|
---|
| 64 | export interface BlockSequence {
|
---|
| 65 | type: 'block-seq';
|
---|
| 66 | offset: number;
|
---|
| 67 | indent: number;
|
---|
| 68 | items: Array<{
|
---|
| 69 | start: SourceToken[];
|
---|
| 70 | key?: never;
|
---|
| 71 | sep?: never;
|
---|
| 72 | value?: Token;
|
---|
| 73 | }>;
|
---|
| 74 | }
|
---|
| 75 | export type CollectionItem = {
|
---|
| 76 | start: SourceToken[];
|
---|
| 77 | key?: Token | null;
|
---|
| 78 | sep?: SourceToken[];
|
---|
| 79 | value?: Token;
|
---|
| 80 | };
|
---|
| 81 | export interface FlowCollection {
|
---|
| 82 | type: 'flow-collection';
|
---|
| 83 | offset: number;
|
---|
| 84 | indent: number;
|
---|
| 85 | start: SourceToken;
|
---|
| 86 | items: CollectionItem[];
|
---|
| 87 | end: SourceToken[];
|
---|
| 88 | }
|
---|
| 89 | export type Token = SourceToken | ErrorToken | Directive | Document | DocumentEnd | FlowScalar | BlockScalar | BlockMap | BlockSequence | FlowCollection;
|
---|
| 90 | export type TokenType = SourceToken['type'] | DocumentEnd['type'] | FlowScalar['type'];
|
---|
| 91 | /** The byte order mark */
|
---|
| 92 | export declare const BOM = "\uFEFF";
|
---|
| 93 | /** Start of doc-mode */
|
---|
| 94 | export declare const DOCUMENT = "\u0002";
|
---|
| 95 | /** Unexpected end of flow-mode */
|
---|
| 96 | export declare const FLOW_END = "\u0018";
|
---|
| 97 | /** Next token is a scalar value */
|
---|
| 98 | export declare const SCALAR = "\u001F";
|
---|
| 99 | /** @returns `true` if `token` is a flow or block collection */
|
---|
| 100 | export declare const isCollection: (token: Token | null | undefined) => token is BlockMap | BlockSequence | FlowCollection;
|
---|
| 101 | /** @returns `true` if `token` is a flow or block scalar; not an alias */
|
---|
| 102 | export declare const isScalar: (token: Token | null | undefined) => token is BlockScalar | FlowScalar;
|
---|
| 103 | /** Get a printable representation of a lexer token */
|
---|
| 104 | export declare function prettyToken(token: string): string;
|
---|
| 105 | /** Identify the type of a lexer token. May return `null` for unknown tokens. */
|
---|
| 106 | export declare function tokenType(source: string): TokenType | null;
|
---|