See details: ../src/ast.ts
interface Node {
type: string;
loc: SourceLocation;
range: [number, number];
}
All nodes have type
, range
, loc
and parent
properties according to ESLint - The AST specification.
interface YAMLMapping extends Node {
type: "YAMLMapping"
style: "block" | "flow"
pairs: YAMLPair[]
parent: YAMLDocument | YAMLPair | YAMLSequence | YAMLWithMeta
}
This is mappings.
style
... If"block"
, it is block style mapping. If"flow"
, it is flow style mapping. e.g.{ foo: bar }
pairs
... An array ofkey: value
pairs.
interface YAMLPair extends Node {
type: "YAMLPair"
key: YAMLMapping | YAMLSequence | YAMLScalar | YAMLAlias | YAMLWithMeta | null
value: YAMLMapping | YAMLSequence | YAMLScalar | YAMLAlias | YAMLWithMeta | null
parent: YAMLMapping
}
This is key: value
pairs.
interface YAMLSequence extends Node {
type: "YAMLSequence"
style: "block" | "flow"
entries: (YAMLMapping | YAMLSequence | YAMLScalar | YAMLAlias | YAMLWithMeta)[]
parent: YAMLDocument | YAMLPair | YAMLSequence | YAMLWithMeta
}
This is sequences.
style
... If"block"
, it is block style sequence. If"flow"
, it is flow style sequence. e.g.{ foo: bar }
entries
... An array of sequence entries.
interface YAMLScalar extends Node {
type: "YAMLScalar"
style: "plain" | "double-quoted" | "single-quoted" | "literal" | "folded"
value: string | number | boolean | null
parent: YAMLDocument | YAMLPair | YAMLSequence | YAMLWithMeta
}
This is scalars.
interface YAMLPlainScalar extends YAMLScalar {
style: "plain"
strValue: string
raw: string
}
This is plain style scalars (unquoted scalars).
interface YAMLDoubleQuotedScalar extends YAMLScalar {
style: "double-quoted"
strValue: string
value: string
raw: string
}
This is double-quoted style scalars.
interface YAMLSingleQuotedScalar extends YAMLScalar {
style: "single-quoted"
strValue: string
value: string
raw: string
}
This is single-quoted style scalars.
interface YAMLBlockLiteralScalar extends YAMLScalar {
style: "literal"
chomping: "clip" | "keep" | "strip"
indent: null | number
value: string
}
This is literal style scalars.
e.g.
|
foo
bar
chomping
"clip"
... The chomping indicator is not specified."strip"
... The-
chomping indicator is specified."keep"
... The+
chomping indicator is specified.
indent
... The specified indentation indicator. It is null if not specified.
interface YAMLBlockFoldedScalar extends YAMLScalar {
style: "folded"
chomping: "clip" | "keep" | "strip"
indent: null | number
value: string
}
This is folded style scalars.
e.g.
>
foo
bar
interface YAMLAlias extends Node {
type: "YAMLAlias"
name: string
parent: YAMLDocument | YAMLPair | YAMLSequence | YAMLWithMeta
}
This is aliases.
interface YAMLWithMeta extends Node {
type: "YAMLWithMeta"
anchor: YAMLAnchor | null
tag: YAMLTag | null
value: YAMLMapping | YAMLSequence | YAMLScalar | YAMLAlias | null
parent: YAMLDocument | YAMLPair | YAMLSequence
}
If it has a tag or anchor, the content node will be wrapped in this node.
interface YAMLAnchor extends Node {
type: "YAMLAnchor"
name: string
parent: YAMLWithMeta
}
interface YAMLTag extends Node {
type: "YAMLTag"
tag: string
parent: YAMLWithMeta
}
interface YAMLDocument extends Node {
type: "YAMLDocument"
directives: YAMLDirective[]
content: YAMLMapping | YAMLSequence | YAMLScalar | YAMLAlias | YAMLWithMeta | null
parent: YAMLProgram
anchors: { [key: string]: YAMLAnchor[] }
// YAML version
version: string
}
interface YAMLDirective extends Node {
type: "YAMLDirective"
value: string
parent: YAMLDocument
}
This is directives. In the following example, %YAML 1.2
is represented by this node.
%YAML 1.2
---
"foo"
extend interface Program {
body: YAMLDocument[]
}
The body
of the Program
node generated by this parser is an array of YAMLDocument
.