YAML (YAML Spec v1.2) grammar for tree-sitter
npm install tree-sitter-yaml tree-sitter
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)))))))))))
MIT © Ika