Skip to content

getgrit/tree-sitter-yaml

 
 

Repository files navigation

tree-sitter-yaml

npm build

YAML (YAML Spec v1.2) grammar for tree-sitter

Changelog

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

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 54.7%
  • C++ 44.7%
  • Shell 0.6%