Skip to content

Commit

Permalink
update tree-sitter to v0.20, add header support(fixes #6)
Browse files Browse the repository at this point in the history
  • Loading branch information
polarmutex committed Sep 7, 2021
1 parent 518d02d commit 79ae7c1
Show file tree
Hide file tree
Showing 9 changed files with 4,293 additions and 3,533 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "beancount grammar for the tree-sitter parsing library"
version = "0.0.1"
keywords = ["incremental", "parsing", "beancount"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-javascript"
repository = "https://github.com/tree-sitter/tree-sitter-beancount"
edition = "2018"
license = "MIT"

Expand All @@ -20,7 +20,7 @@ include = [
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "0.19.3"
tree-sitter = "~0.20.0"

[build-dependencies]
cc = "1.0"
21 changes: 20 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,24 @@ module.exports = grammar({
$._entry,
$._skipped_lines,
),

_markdown_heading: $ => seq(
repeat1($._hash),
/.*/,
$._eol
),

_orgmode_heading: $ => seq(
repeat1($.asterisk),
/.*/,
$._eol
),

heading: $ => choice(
$._markdown_heading,
$._orgmode_heading
),

/* End Grammar Rules */
/*--------------------------------------------------------------------------------*/

Expand All @@ -653,7 +671,8 @@ module.exports = grammar({
seq(
$.comment,
$._eol
)
),
$.heading
),

_ASCII: $ => /[\x00-\x7f]/,
Expand Down
41 changes: 7 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"homepage": "https://github.com/bryall/tree-sitter-beancount#readme",
"dependencies": {
"nan": "^2.14.1"
"nan": "^2.15.0"
},
"devDependencies": {
"tree-sitter-cli": "^0.19.0"
"tree-sitter-cli": "0.20.0"
}
}
13 changes: 13 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let
pkgs = import <nixpkgs> {};
in
pkgs.mkShell rec {
name = "tree-sitter";

buildInputs = with pkgs; [
nodejs-14_x
python38Full
tree-sitter
];

}
57 changes: 57 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2637,6 +2637,59 @@
}
]
},
"_markdown_heading": {
"type": "SEQ",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_hash"
}
},
{
"type": "PATTERN",
"value": ".*"
},
{
"type": "SYMBOL",
"name": "_eol"
}
]
},
"_orgmode_heading": {
"type": "SEQ",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "asterisk"
}
},
{
"type": "PATTERN",
"value": ".*"
},
{
"type": "SYMBOL",
"name": "_eol"
}
]
},
"heading": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_markdown_heading"
},
{
"type": "SYMBOL",
"name": "_orgmode_heading"
}
]
},
"identifier": {
"type": "PATTERN",
"value": "[a-z]+"
Expand Down Expand Up @@ -2698,6 +2751,10 @@
"name": "_eol"
}
]
},
{
"type": "SYMBOL",
"name": "heading"
}
]
},
Expand Down
19 changes: 19 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@
"type": "flag",
"named": true
},
{
"type": "heading",
"named": true
},
{
"type": "include",
"named": true
Expand Down Expand Up @@ -703,6 +707,21 @@
]
}
},
{
"type": "heading",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "asterisk",
"named": true
}
]
}
},
{
"type": "include",
"named": true,
Expand Down
Loading

0 comments on commit 79ae7c1

Please sign in to comment.