Start of doc-mode
Unexpected end of flow-mode
Next token is a scalar value
Create a new scalar token with value
Values that represent an actual string but may be parsed as a different type should use a type
other than 'PLAIN'
,
as this function does not support any schema operations and won't check for such conflicts.
The string representation of the value, which will have its content properly indented.
Comments and whitespace after the end of the value, or after the block scalar header. If undefined, a newline will be added.
Being within an implicit key may affect the resolved type of the token's value.
Is this scalar within a flow collection? This may affect the resolved type of the token's value.
The indent level of the token.
The offset position of the token.
The preferred type of the scalar token. If undefined, the previous type of the token
will be used, defaulting to 'PLAIN'
.
true
if token
is a flow or block collection
true
if token
is a flow or block scalar; not an alias
Get a printable representation of a lexer token
If token
is a CST flow or block scalar, determine its string value and a few other attributes.
Otherwise, return null
.
Set the value of token
to the given string value
, overwriting any previous contents and type that it may have.
Best efforts are made to retain any comments previously associated with the token
,
though all contents within a collection's items
will be overwritten.
Values that represent an actual string but may be parsed as a different type should use a type
other than 'PLAIN'
,
as this function does not support any schema operations and won't check for such conflicts.
Any token. If it does not include an indent
value, the value will be stringified as if it were an implicit key.
The string representation of the value, which will have its content properly indented.
In most cases, values after a key should have an additional level of indentation.
Being within an implicit key may affect the resolved type of the token's value.
Being within a flow collection may affect the resolved type of the token's value.
The preferred type of the scalar token. If undefined, the previous type of the token
will be used, defaulting to 'PLAIN'
.
Stringify a CST document, token, or collection item
Fair warning: This applies no validation whatsoever, and simply concatenates the sources in their logical order.
Identify the type of a lexer token. May return null
for unknown tokens.
Apply a visitor to a CST document or item.
Walks through the tree (depth-first) starting from the root, calling a
visitor
function with two arguments when entering each item:
item
: The current item, which included the following members:start: SourceToken[]
– Source tokens before the key or value,
possibly including its anchor or tag.key?: Token | null
– Set for pair values. May then be null
, if
the key before the :
separator is empty.sep?: SourceToken[]
– Source tokens between the key and the value,
which should include the :
map value indicator if value
is set.value?: Token
– The value of a sequence item, or of a map pair.path
: The steps from the root to the current node, as an array of
['key' | 'value', number]
tuples.The return value of the visitor may be used to control the traversal:
undefined
(default): Do nothing and continuevisit.SKIP
: Do not visit the children of this token, continue with
next siblingvisit.BREAK
: Terminate traversal completelyvisit.REMOVE
: Remove the current item, then continue with the next onenumber
: Set the index of the next step. This is useful especially if
the index of the current token has changed.function
: Define the next visitor for this item. After the original
visitor is called on item entry, next visitors are called after handling
a non-empty key
and when exiting the item.Generated using TypeDoc
The byte order mark