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 | explicitKey?: true;
|
55 | key?: never;
|
56 | sep?: never;
|
57 | value?: never;
|
58 | } | {
|
59 | start: SourceToken[];
|
60 | explicitKey?: true;
|
61 | key: Token | null;
|
62 | sep: SourceToken[];
|
63 | value?: Token;
|
64 | }>;
|
65 | }
|
66 | export interface BlockSequence {
|
67 | type: 'block-seq';
|
68 | offset: number;
|
69 | indent: number;
|
70 | items: Array<{
|
71 | start: SourceToken[];
|
72 | key?: never;
|
73 | sep?: never;
|
74 | value?: Token;
|
75 | }>;
|
76 | }
|
77 | export type CollectionItem = {
|
78 | start: SourceToken[];
|
79 | key?: Token | null;
|
80 | sep?: SourceToken[];
|
81 | value?: Token;
|
82 | };
|
83 | export interface FlowCollection {
|
84 | type: 'flow-collection';
|
85 | offset: number;
|
86 | indent: number;
|
87 | start: SourceToken;
|
88 | items: CollectionItem[];
|
89 | end: SourceToken[];
|
90 | }
|
91 | export type Token = SourceToken | ErrorToken | Directive | Document | DocumentEnd | FlowScalar | BlockScalar | BlockMap | BlockSequence | FlowCollection;
|
92 | export type TokenType = SourceToken['type'] | DocumentEnd['type'] | FlowScalar['type'];
|
93 |
|
94 | export declare const BOM = "\uFEFF";
|
95 |
|
96 | export declare const DOCUMENT = "\u0002";
|
97 |
|
98 | export declare const FLOW_END = "\u0018";
|
99 |
|
100 | export declare const SCALAR = "\u001F";
|
101 |
|
102 | export declare const isCollection: (token: Token | null | undefined) => token is BlockMap | BlockSequence | FlowCollection;
|
103 |
|
104 | export declare const isScalar: (token: Token | null | undefined) => token is FlowScalar | BlockScalar;
|
105 |
|
106 | export declare function prettyToken(token: string): string;
|
107 |
|
108 | export declare function tokenType(source: string): TokenType | null;
|