import { Parser } from "https://deno.land/x/windmill@v1.323.4/node_modules/yaml/browser/dist/index.js";
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
}
Methods
atIndentedComment(start, indent)
blockMap(map)
blockScalar(scalar)
blockSequence(seq)
document(doc)
documentEnd(docEnd)
end()
Call at end of input to push out any remaining constructions
flowCollection(fc)
flowScalar(type)
lineEnd(token)
next(source)
Advance the parser by the source
of one lexical token.
parse(source, incomplete?)
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.
peek(n)
pop(error)
scalar(scalar)
startBlockValue(parent)
step()
stream()