tree-sitter-yaml
v0.5.0
Published
YAML grammar for tree-sitter
Downloads
1,551,962
Readme
tree-sitter-yaml
YAML (YAML Spec v1.2) grammar for tree-sitter
Install
npm install tree-sitter-yaml tree-sitter
Usage
const Parser = require("tree-sitter");
const YAML = require("tree-sitter-yaml");
const parser = new Parser();
parser.setLanguage(YAML);
const sourceCode = `
!!map
hello: &anchor
- world
`;
const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());
// (stream
// (document
// (block_node
// (tag)
// (block_mapping
// (block_mapping_pair
// key: (flow_node
// (plain_scalar
// (string_scalar)))
// value: (block_node
// (anchor)
// (block_sequence
// (block_sequence_item
// (flow_node
// (plain_scalar
// (string_scalar)))))))))))
License
MIT © Ika