Skip to main content

Crate treesitter_types_yaml

Crate treesitter_types_yaml 

Source
Expand description

Strongly-typed AST types for YAML, auto-generated from tree-sitter-yaml’s node-types.json.

This crate is generated by treesitter-types and is automatically kept up to date when a new version of the grammar crate is released.

See the Tree-sitter project for more information about the underlying parser framework.

§Example

use treesitter_types_yaml::*;

// A small YAML document.
let src = b"\
name: hello
version: 1.0.0
dependencies:
  - foo
  - bar
";

// Parse the source with tree-sitter and convert into typed AST.
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_yaml::LANGUAGE.into()).unwrap();
let tree = parser.parse(src, None).unwrap();
let stream = Stream::from_node(tree.root_node(), src).unwrap();

// A YAML stream contains one or more documents.
assert_eq!(stream.children.len(), 1);

// The document contains the top-level mapping.
let doc = &stream.children[0];
assert!(!doc.children.is_empty());
assert_eq!(doc.span.start.row, 0);

Re-exports§

pub use tree_sitter_yaml;
pub use treesitter_types::tree_sitter;

Structs§

Alias
AliasName
Anchor
AnchorName
BlockMapping
BlockMappingPair
BlockNode
BlockScalar
BlockSequence
BlockSequenceItem
BooleanScalar
Comment
DirectiveName
DirectiveParameter
Document
DoubleQuoteScalar
EscapeSequence
FloatScalar
FlowMapping
FlowNode
FlowPair
FlowSequence
IntegerScalar
NullScalar
PlainScalar
ReservedDirective
SingleQuoteScalar
Span
Stream
StringScalar
Tag
TagDirective
TagHandle
TagPrefix
TimestampScalar
YamlDirective
YamlVersion

Enums§

AnyNode
BlockMappingPairKey
BlockMappingPairValue
BlockNodeChildren
BlockSequenceItemChildren
DocumentChildren
FlowMappingChildren
FlowNodeChildren
FlowSequenceChildren
ParseError
PlainScalarChildren
ReservedDirectiveChildren
TagDirectiveChildren

Traits§

FromNode
Every generated struct and enum implements this.
LeafNode
Implemented by every generated leaf type (identifiers, literals, etc.)
Spanned
Implemented by every generated type that has a source location.