Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/windmill/node_modules/yaml/dist/parse/parser.d.ts>Parser

Windmill deno client (separated from the main repo because most of the code is auto-generated from the openapi and not worth committing)
Go to Latest
class Parser
import { Parser } from "https://deno.land/x/windmill@v1.423.1/node_modules/yaml/dist/parse/parser.d.ts";

A YAML concrete syntax tree (CST) parser

const src: string = ...
for (const token of new Parser().parse(src)) {
  // token: Token
}

To use the parser with a user-provided lexer:

function* parse(source: string, lexer: Lexer) {
  const parser = new Parser()
  for (const lexeme of lexer.lex(source))
    yield* parser.next(lexeme)
  yield* parser.end()
}

const src: string = ...
const lexer = new Lexer()
for (const token of parse(src, lexer)) {
  // token: Token
}

Constructors

new
Parser(onNewLine?: (offset: number) => void)

Properties

private
atIndentedComment
private
atNewLine

If true, space and sequence indicators count as indentation

private
atScalar

If true, next token is a scalar value

private
blockMap
private
blockScalar
private
blockSequence
private
document
private
documentEnd
private
flowCollection
private
flowScalar
private
indent

Current indentation level

private
lexer
private
lineEnd
private
onKeyLine

On the same line with a block map key

private
optional
onNewLine
private
peek
private
pop
private
scalar
private
source

The source of the current token, set in parse()

private
readonly
sourceToken
private
startBlockValue
private
step
private
stream
private
type

The type of the current token, set in parse()

offset: number

Current offset since the start of parsing

stack: Token[]

Top indicates the node that's currently being built

Methods

end(): Generator<Token, void, unknown>

Call at end of input to push out any remaining constructions

next(source: string): Generator<Token, void, unknown>

Advance the parser by the source of one lexical token.

parse(source: string, incomplete?: boolean): Generator<Token, void, unknown>

Parse source as a YAML stream. If incomplete, a part of the last line may be left as a buffer for the next call.

Errors are not thrown, but yielded as { type: 'error', message } tokens.