Skip to content

Commit

Permalink
feat: initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Oct 4, 2019
0 parents commit 4da98f7
Show file tree
Hide file tree
Showing 25 changed files with 7,368 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[corpus/*]
trim_trailing_whitespace = false
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text eol=lf
*.wasm binary

/src/** linguist-generated
/src/scanner.* linguist-generated=false
/index.js linguist-generated
/binding.gyp linguist-detectable=false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
/node_modules
/tree-sitter
Empty file added .npmignore
Empty file.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: rust

rust:
- stable

script:
- if [ ! -d "./tree-sitter/target/release" ]; then bash ./scripts/setup-tree-sitter.sh; fi
- ./tree-sitter/target/release/tree-sitter test

cache:
cargo: true
directories:
- ./tree-sitter
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Ika <ikatyang@gmail.com> (https://github.com/ikatyang)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# tree-sitter-vue

[![npm](https://img.shields.io/npm/v/tree-sitter-vue.svg)](https://www.npmjs.com/package/tree-sitter-vue)
[![build](https://img.shields.io/travis/com/ikatyang/tree-sitter-vue/master.svg)](https://travis-ci.com/ikatyang/tree-sitter-vue/builds)

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)

_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._

[Changelog](https://github.com/ikatyang/tree-sitter-vue/blob/master/CHANGELOG.md)

## Install

```sh
npm install tree-sitter-vue tree-sitter
```

## Usage

```js
const Parser = require("tree-sitter");
const Vue = require("tree-sitter-vue");

const parser = new Parser();
parser.setLanguage(Vue);

const sourceCode = `
<template>
Hello, <a :[key]="url">{{ name }}</a>!
</template>
`;

const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());
// (component
// (template_element
// (start_tag
// (tag_name))
// (text)
// (element
// (start_tag
// (tag_name)
// (directive_attribute
// (directive_name)
// (directive_dynamic_argument
// (directive_dynamic_argument_value))
// (quoted_attribute_value
// (attribute_value))))
// (interpolation
// (raw_text))
// (end_tag
// (tag_name)))
// (text)
// (end_tag
// (tag_name))))
```

## License

MIT © [Ika](https://github.com/ikatyang)
29 changes: 29 additions & 0 deletions ThirdPartyNoticeText.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
This project incorporates third party material from the projects listed below.
The original copyright notice and the license under which we received such third
party material are set forth below.

================================================================================

tree-sitter-html (https://github.com/tree-sitter/tree-sitter-html)

The MIT License (MIT)

Copyright (c) 2014 Max Brunsfeld

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 19 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"targets": [
{
"target_name": "tree_sitter_vue_binding",
"include_dirs": [
"<!(node -e \"require('nan')\")",
"src"
],
"sources": [
"src/binding.cc",
"src/parser.c",
"src/scanner.cc"
],
"cflags_c": [
"-std=c99",
]
}
]
}
Loading

0 comments on commit 4da98f7

Please sign in to comment.