Skip to content

Commit

Permalink
preparing for publication
Browse files Browse the repository at this point in the history
  • Loading branch information
uben0 committed Aug 11, 2023
1 parent 5b607db commit 36fc3d5
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 51 deletions.
26 changes: 26 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "tree-sitter-tester"
description = "tester grammar for the tree-sitter parsing library"
version = "0.0.1"
keywords = ["incremental", "parsing", "tester"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-tester"
edition = "2018"
license = "MIT"

build = "bindings/rust/build.rs"
include = [
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]

[lib]
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "~0.20.10"

[build-dependencies]
cc = "1.0"
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_tester_binding",
"include_dirs": [
"<!(node -e \"require('nan')\")",
"src"
],
"sources": [
"bindings/node/binding.cc",
"src/parser.c",
# If your language uses an external scanner, add it here.
],
"cflags_c": [
"-std=c99",
]
}
]
}
73 changes: 22 additions & 51 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ module.exports = grammar({
[$._space_lp],
[$._space_lp, $._normal_tail_condition_line],
[$._heading_tail_any_text],
[$._heading_tail_any_raw],
[$._heading_tail_any_math],
[$._heading_tail_any_element],
// [$._heading_tail_any_math],
[$._heading_tail_any_strong],
[$._heading_tail_any_emph],
[$._heading_tail_any_code],
Expand Down Expand Up @@ -134,7 +134,7 @@ module.exports = grammar({
seq($._space_l0, optional(seq(choice($._space_l1, $._space_lp), optional($._space_l0)))),
seq(choice($._space_l1, $._space_lp), optional($._space_l0)),
)),
_element: $ => choice($.raw, $.inline, $.strong, $.emph),
_element: $ => choice($.raw, $.inline, $.math),
raw: $ => seq('```', field('lang', optional($.ident)), alias(/[^`a-zA-Z](``[^`]|`[^`]|[^`])*/, $.blob), '```'),
inline: $ => seq('`', alias(/[^`]*/, $.blob), '`'),
math: $ => seq('$', /[^\$]*/, '$'),
Expand All @@ -143,61 +143,53 @@ module.exports = grammar({
$._normal_tail_any_line,
$._normal_tail_any_break,
$._normal_tail_any_code,
$._normal_tail_any_element,
$._normal_tail_any_strong,
$._normal_tail_any_emph,
$._normal_tail_any_raw,
$._normal_tail_any_math,
),
_any_strong: $ => choice(
$._strong_tail_any_line,
$._strong_tail_any_code,
$._strong_tail_any_emph,
$._strong_tail_any_raw,
$._strong_tail_any_math,
$._strong_tail_any_element,
),
_any_emph: $ => choice(
$._emph_tail_any_line,
$._emph_tail_any_code,
$._emph_tail_any_strong,
$._emph_tail_any_raw,
$._emph_tail_any_math,
$._emph_tail_any_element,
),
_any_heading: $ => choice(
$._heading_tail_any_code,
$._heading_tail_any_strong,
$._heading_tail_any_emph,
$._heading_tail_any_raw,
$._heading_tail_any_math,
$._heading_tail_any_element,
),
_any_normal_space: $ => choice(
$._normal_tail_any_space,
$._normal_tail_any_code,
$._normal_tail_any_strong,
$._normal_tail_any_emph,
$._normal_tail_any_raw,
$._normal_tail_any_math,
$._normal_tail_any_element,
),
_any_strong_space: $ => choice(
$._strong_tail_any_space,
$._strong_tail_any_code,
$._strong_tail_any_emph,
$._strong_tail_any_raw,
$._strong_tail_any_math,
$._strong_tail_any_element,
),
_any_emph_space: $ => choice(
$._emph_tail_any_space,
$._emph_tail_any_code,
$._emph_tail_any_strong,
$._emph_tail_any_raw,
$._emph_tail_any_math,
$._emph_tail_any_element,
),
_any_heading_space: $ => choice(
$._heading_tail_any_space,
$._heading_tail_any_code,
$._heading_tail_any_strong,
$._heading_tail_any_emph,
$._heading_tail_any_raw,
$._heading_tail_any_math,
$._heading_tail_any_element,
),

// TAIL INIT
Expand Down Expand Up @@ -233,12 +225,7 @@ module.exports = grammar({
$._normal_tail_any_text,
$._any_normal,
))),
_normal_tail_any_raw: $ => seq($.raw, optional(choice(
$._normal_tail_any_space,
$._normal_tail_any_text,
$._any_normal,
))),
_normal_tail_any_math: $ => seq($.math, optional(choice(
_normal_tail_any_element: $ => seq($._element, optional(choice(
$._normal_tail_any_space,
$._normal_tail_any_text,
$._any_normal,
Expand All @@ -251,12 +238,7 @@ module.exports = grammar({
$._strong_tail_any_space,
$._any_strong,
))),
_strong_tail_any_raw: $ => seq($.raw, optional(choice(
$._strong_tail_any_space,
$._strong_tail_any_text,
$._any_strong,
))),
_strong_tail_any_math: $ => seq($.math, optional(choice(
_strong_tail_any_element: $ => seq($._element, optional(choice(
$._strong_tail_any_space,
$._strong_tail_any_text,
$._any_strong,
Expand All @@ -269,12 +251,7 @@ module.exports = grammar({
$._emph_tail_any_space,
$._any_emph,
))),
_emph_tail_any_raw: $ => seq($.raw, optional(choice(
$._emph_tail_any_space,
$._emph_tail_any_text,
$._any_emph,
))),
_emph_tail_any_math: $ => seq($.math, optional(choice(
_emph_tail_any_element: $ => seq($._element, optional(choice(
$._emph_tail_any_space,
$._emph_tail_any_text,
$._any_emph,
Expand All @@ -287,12 +264,7 @@ module.exports = grammar({
$._heading_tail_any_space,
$._any_heading,
))),
_heading_tail_any_raw: $ => seq($.raw, optional(choice(
$._heading_tail_any_space,
$._heading_tail_any_text,
$._any_heading,
))),
_heading_tail_any_math: $ => seq($.math, optional(choice(
_heading_tail_any_element: $ => seq($._element, optional(choice(
$._heading_tail_any_space,
$._heading_tail_any_text,
$._any_heading,
Expand All @@ -315,33 +287,29 @@ module.exports = grammar({
$._normal_tail_any_code,
$._normal_tail_any_strong,
$._normal_tail_any_emph,
$._normal_tail_any_raw,
$._normal_tail_any_math,
$._normal_tail_any_element,
))),
_normal_tail_any_break: $ => seq(alias($._space_lp, $.break), optional($._space_l0), optional(choice(
$._normal_tail_init_text,
$._normal_tail_init_heading,
$._normal_tail_any_code,
$._normal_tail_any_strong,
$._normal_tail_any_emph,
$._normal_tail_any_raw,
$._normal_tail_any_math,
$._normal_tail_any_element,
))),
_strong_tail_any_line: $ => seq($._space_l1, optional(choice(
$._strong_tail_init_text,
$._strong_tail_init_heading,
$._strong_tail_any_code,
$._strong_tail_any_emph,
$._strong_tail_any_raw,
$._strong_tail_any_math,
$._strong_tail_any_element,
))),
_emph_tail_any_line: $ => seq($._space_l1, optional(choice(
$._emph_tail_init_text,
$._emph_tail_init_heading,
$._emph_tail_any_code,
$._emph_tail_any_strong,
$._emph_tail_any_raw,
$._emph_tail_any_math,
$._emph_tail_any_element,
))),

// TAIL ITEM
Expand Down Expand Up @@ -370,20 +338,23 @@ module.exports = grammar({
$._normal_tail_any_code,
$._normal_tail_any_strong,
$._normal_tail_any_emph,
$._normal_tail_any_element,
))),
_normal_tail_condition_break: $ => seq(alias($._space_lp, $.break), optional(choice(
$._normal_tail_condition_space,
$._normal_tail_condition_text,
$._normal_tail_any_code,
$._normal_tail_any_strong,
$._normal_tail_any_emph,
$._normal_tail_any_element,
))),
_normal_tail_condition_line: $ => seq($._space_l1, optional(choice(
$._normal_tail_condition_space,
$._normal_tail_condition_text,
$._normal_tail_any_code,
$._normal_tail_any_strong,
$._normal_tail_any_emph,
$._normal_tail_any_element,
))),
_normal_tail_condition_text: $ => seq(alias($._text_next_condition, $.text), optional(choice(
$._normal_tail_any_space,
Expand Down
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tree-sitter-test",
"version": "1.0.0",
"description": "",
"main": "bindings/node",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"nan": "^2.17.0"
}
}

0 comments on commit 36fc3d5

Please sign in to comment.