Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikatyang/tree-sitter-yaml
YAML grammar for tree-sitter
https://github.com/ikatyang/tree-sitter-yaml
grammar tree-sitter yaml
Last synced: about 1 month ago
JSON representation
YAML grammar for tree-sitter
- Host: GitHub
- URL: https://github.com/ikatyang/tree-sitter-yaml
- Owner: ikatyang
- License: mit
- Created: 2019-08-31T11:12:53.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-05T21:44:28.000Z (about 1 year ago)
- Last Synced: 2024-04-14T11:56:47.891Z (7 months ago)
- Topics: grammar, tree-sitter, yaml
- Language: JavaScript
- Homepage: https://ikatyang.github.io/tree-sitter-yaml/
- Size: 1.19 MB
- Stars: 86
- Watchers: 7
- Forks: 32
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tree-sitter-yaml
[![npm](https://img.shields.io/npm/v/tree-sitter-yaml.svg)](https://www.npmjs.com/package/tree-sitter-yaml)
[![build](https://img.shields.io/travis/com/ikatyang/tree-sitter-yaml/master.svg)](https://travis-ci.com/ikatyang/tree-sitter-yaml/builds)YAML ([YAML Spec v1.2](https://yaml.org/spec/1.2/spec.html)) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
[Changelog](https://github.com/ikatyang/tree-sitter-yaml/blob/master/CHANGELOG.md)
## Install
```sh
npm install tree-sitter-yaml tree-sitter
```## Usage
```js
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](https://github.com/ikatyang)