Crate yaml_parser

Source
Expand description

Semi-tolerant YAML concrete syntax tree parser.

§Usage

let code = "";
match yaml_parser::parse(code) {
    Ok(tree) => println!("{tree:#?}"),
    Err(err) => eprintln!("{err}"),
};

It produces rowan tree if succeeded. For consuming the tree, see rowan’s docs.

To build AST from CST:

use yaml_parser::{ast::{AstNode, Root}, parse};

let code = "";
let tree = parse(code).unwrap();
let ast = Root::cast(tree);
assert!(matches!(ast, Some(Root { .. })));

Modules§

ast
Abstract Syntax Tree, layered on top of untyped SyntaxNodes.

Structs§

SyntaxError
Error type for syntax errors.

Enums§

SyntaxKind
Syntax kind enum for nodes and tokens.
YamlLanguage

Functions§

parse
Parse the given YAML code into CST.

Type Aliases§

SyntaxElement
SyntaxNode
SyntaxToken