Skip to content

Commit 4da98f7

Browse files
committed
feat: initial implementation
0 parents  commit 4da98f7

25 files changed

+7368
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[corpus/*]
12+
trim_trailing_whitespace = false

.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* text eol=lf
2+
*.wasm binary
3+
4+
/src/** linguist-generated
5+
/src/scanner.* linguist-generated=false
6+
/index.js linguist-generated
7+
/binding.gyp linguist-detectable=false

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build
2+
/node_modules
3+
/tree-sitter

.npmignore

Whitespace-only changes.

.travis.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: rust
2+
3+
rust:
4+
- stable
5+
6+
script:
7+
- if [ ! -d "./tree-sitter/target/release" ]; then bash ./scripts/setup-tree-sitter.sh; fi
8+
- ./tree-sitter/target/release/tree-sitter test
9+
10+
cache:
11+
cargo: true
12+
directories:
13+
- ./tree-sitter

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Ika <[email protected]> (https://github.com/ikatyang)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# tree-sitter-vue
2+
3+
[![npm](https://img.shields.io/npm/v/tree-sitter-vue.svg)](https://www.npmjs.com/package/tree-sitter-vue)
4+
[![build](https://img.shields.io/travis/com/ikatyang/tree-sitter-vue/master.svg)](https://travis-ci.com/ikatyang/tree-sitter-vue/builds)
5+
6+
Vue ([Vue v2.6.0 Template Syntax](https://vuejs.org/v2/guide/syntax.html)) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
7+
8+
_Note: This grammar is not responsible for parsing embedded languages, see [Multi-language Documents](http://tree-sitter.github.io/tree-sitter/using-parsers#multi-language-documents) for more info._
9+
10+
[Changelog](https://github.com/ikatyang/tree-sitter-vue/blob/master/CHANGELOG.md)
11+
12+
## Install
13+
14+
```sh
15+
npm install tree-sitter-vue tree-sitter
16+
```
17+
18+
## Usage
19+
20+
```js
21+
const Parser = require("tree-sitter");
22+
const Vue = require("tree-sitter-vue");
23+
24+
const parser = new Parser();
25+
parser.setLanguage(Vue);
26+
27+
const sourceCode = `
28+
<template>
29+
Hello, <a :[key]="url">{{ name }}</a>!
30+
</template>
31+
`;
32+
33+
const tree = parser.parse(sourceCode);
34+
console.log(tree.rootNode.toString());
35+
// (component
36+
// (template_element
37+
// (start_tag
38+
// (tag_name))
39+
// (text)
40+
// (element
41+
// (start_tag
42+
// (tag_name)
43+
// (directive_attribute
44+
// (directive_name)
45+
// (directive_dynamic_argument
46+
// (directive_dynamic_argument_value))
47+
// (quoted_attribute_value
48+
// (attribute_value))))
49+
// (interpolation
50+
// (raw_text))
51+
// (end_tag
52+
// (tag_name)))
53+
// (text)
54+
// (end_tag
55+
// (tag_name))))
56+
```
57+
58+
## License
59+
60+
MIT © [Ika](https://github.com/ikatyang)

ThirdPartyNoticeText.txt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
This project incorporates third party material from the projects listed below.
2+
The original copyright notice and the license under which we received such third
3+
party material are set forth below.
4+
5+
================================================================================
6+
7+
tree-sitter-html (https://github.com/tree-sitter/tree-sitter-html)
8+
9+
The MIT License (MIT)
10+
11+
Copyright (c) 2014 Max Brunsfeld
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a copy
14+
of this software and associated documentation files (the "Software"), to deal
15+
in the Software without restriction, including without limitation the rights
16+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
copies of the Software, and to permit persons to whom the Software is
18+
furnished to do so, subject to the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all
21+
copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
SOFTWARE.

binding.gyp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name": "tree_sitter_vue_binding",
5+
"include_dirs": [
6+
"<!(node -e \"require('nan')\")",
7+
"src"
8+
],
9+
"sources": [
10+
"src/binding.cc",
11+
"src/parser.c",
12+
"src/scanner.cc"
13+
],
14+
"cflags_c": [
15+
"-std=c99",
16+
]
17+
}
18+
]
19+
}

0 commit comments

Comments
 (0)