chore: use tree-sitter-cli@0.15.9-custom

This commit is contained in:
Ika 2019-09-30 15:14:55 +08:00
parent cca06a9f61
commit 1e70956efb
11 changed files with 2122 additions and 1933 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/build
/node_modules
/tree-sitter

View file

@ -1,3 +0,0 @@
{
"trailingComma": "all"
}

View file

@ -1,16 +1,13 @@
language: node_js
language: rust
node_js:
rust:
- stable
script:
- yarn lint
- yarn test
- if [ ! -d "./tree-sitter/target/release" ]; then bash ./scripts/setup-tree-sitter.sh; fi
- ./tree-sitter/target/release/tree-sitter test
cache:
yarn: true
cargo: true
directories:
- node_modules
matrix:
fast_finish: true
- ./tree-sitter

View file

@ -28,9 +28,13 @@ key
(document
(pair
(key) (ERROR) (boolean))
(key)
(ERROR)
(boolean))
(pair
(key) (ERROR) (boolean)))
(key)
(ERROR)
(boolean)))
================================================================================
INVALID - float - whitespaces between its components are not allowed
@ -44,7 +48,8 @@ invalid_both = 1 .0 e 2
(document
(ERROR
(key) (integer)))
(key)
(integer)))
================================================================================
INVALID - offset date time - whitespaces between its components are not allowed
@ -57,7 +62,10 @@ invalid2 = 1979-05-27 T 07:32:00 Z
(document
(ERROR
(key) (local_date) (local_time) (local_time)))
(key)
(local_date)
(local_time)
(local_time)))
================================================================================
INVALID - local date time - whitespaces between its components are not allowed
@ -70,7 +78,10 @@ invalid2 = 1979-05-27 T 07:32:00
(document
(ERROR
(key) (local_date) (local_time) (local_time)))
(key)
(local_date)
(local_time)
(local_time)))
================================================================================
VALID - local date - trailing whitespaces are allowed
@ -82,7 +93,8 @@ valid = 1979-05-27
(document
(pair
(key) (local_date)))
(key)
(local_date)))
================================================================================
INVALID - table - multiline string for header keys are not allowed
@ -106,9 +118,11 @@ key
(document
(table
(key) (ERROR))
(key)
(ERROR))
(table
(key) (ERROR)))
(key)
(ERROR)))
================================================================================
INVALID - inline table - newlines outside of pairs are not allowed
@ -126,7 +140,8 @@ key = {
(inline_table
(ERROR)
(pair
(key) (boolean))
(key)
(boolean))
(ERROR))))
================================================================================
@ -151,7 +166,8 @@ key
(document
(ERROR
(key) (key)))
(key)
(key)))
================================================================================
VALID - table - empty content separated by comments
@ -165,7 +181,8 @@ VALID - table - empty content separated by comments
(document
(table
(key) (comment)))
(key)
(comment)))
================================================================================
VALID - array of tables - empty content separated by comments
@ -179,7 +196,8 @@ VALID - array of tables - empty content separated by comments
(document
(table_array_element
(key) (comment)))
(key)
(comment)))
================================================================================
VALID - table - two pairs separated by comments
@ -199,10 +217,12 @@ b = 2
(table
(key)
(pair
(key) (integer))
(key)
(integer))
(comment)
(pair
(key) (integer))))
(key)
(integer))))
================================================================================
VALID - array of tables - two pairs separated by comments
@ -222,7 +242,9 @@ b = 2
(table_array_element
(key)
(pair
(key) (integer))
(key)
(integer))
(comment)
(pair
(key) (integer))))
(key)
(integer))))

View file

@ -10,7 +10,9 @@ key = "value" # This is a comment at the end of a line
(document
(comment)
(pair
(key) (string) (comment)))
(key)
(string)
(comment)))
================================================================================
VALID - key/value pair - basic
@ -22,7 +24,8 @@ key = "value"
(document
(pair
(key) (string)))
(key)
(string)))
================================================================================
INVALID - key/value pair - empty value
@ -34,7 +37,8 @@ key = # INVALID
(document
(ERROR
(key) (comment)))
(key)
(comment)))
================================================================================
VALID - keys - bare keys
@ -49,13 +53,17 @@ bare-key = "value"
(document
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string)))
(key)
(string)))
================================================================================
VALID - keys - quoted keys
@ -71,15 +79,20 @@ VALID - keys - quoted keys
(document
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string)))
(key)
(string)))
================================================================================
INVALID - keys - empty bare key
@ -98,9 +111,13 @@ INVALID - keys - empty bare key
(string)
(comment))
(pair
(key) (string) (comment))
(key)
(string)
(comment))
(pair
(key) (string) (comment)))
(key)
(string)
(comment)))
================================================================================
VALID - keys - dotted keys
@ -115,18 +132,22 @@ site."google.com" = true
(document
(pair
(key) (string))
(pair
(dotted_key
(key) (key))
(key)
(string))
(pair
(dotted_key
(key) (key))
(key)
(key))
(string))
(pair
(dotted_key
(key) (key))
(key)
(key))
(string))
(pair
(dotted_key
(key)
(key))
(boolean)))
================================================================================
@ -142,9 +163,11 @@ name = "Pradyun"
(document
(comment)
(pair
(key) (string))
(key)
(string))
(pair
(key) (string)))
(key)
(string)))
================================================================================
VALID - keys - directly defined nested keys
@ -159,12 +182,14 @@ a.d = 2
(pair
(dotted_key
(dotted_key
(key) (key))
(key)
(key))
(key))
(integer))
(pair
(dotted_key
(key) (key))
(key)
(key))
(integer)))
================================================================================
@ -181,12 +206,14 @@ a.b.c = 2
(comment)
(pair
(dotted_key
(key) (key))
(key)
(key))
(integer))
(pair
(dotted_key
(dotted_key
(key) (key))
(key)
(key))
(key))
(integer)))
@ -202,7 +229,12 @@ str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
(pair
(key)
(string
(escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence))))
(escape_sequence)
(escape_sequence)
(escape_sequence)
(escape_sequence)
(escape_sequence)
(escape_sequence))))
================================================================================
VALID - string - multi-line basic strings
@ -216,7 +248,8 @@ Violets are blue"""
(document
(pair
(key) (string)))
(key)
(string)))
================================================================================
VALID - string - multi-line basic strings with trailing backslashes
@ -243,15 +276,20 @@ str3 = """\
(document
(comment)
(pair
(key) (string))
(key)
(string))
(pair
(key)
(string
(escape_sequence) (escape_sequence)))
(escape_sequence)
(escape_sequence)))
(pair
(key)
(string
(escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence))))
(escape_sequence)
(escape_sequence)
(escape_sequence)
(escape_sequence))))
================================================================================
VALID - string - literal strings
@ -268,13 +306,17 @@ regex = '<\i\c*\s*>'
(document
(comment)
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string)))
(key)
(string)))
================================================================================
VALID - string - multi-line literal strings
@ -292,9 +334,11 @@ trimmed in raw strings.
(document
(pair
(key) (string))
(key)
(string))
(pair
(key) (string)))
(key)
(string)))
================================================================================
VALID - integer - signed/unsigned decimal integer
@ -309,13 +353,17 @@ int4 = -17
(document
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer)))
(key)
(integer)))
================================================================================
VALID - integer - decimal integer with underscores
@ -329,11 +377,15 @@ int7 = 1_2_3_4_5 # VALID but discouraged
(document
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer) (comment)))
(key)
(integer)
(comment)))
================================================================================
VALID - integer - hexadecimal/octal/binary integer
@ -356,19 +408,26 @@ bin1 = 0b11010110
(document
(comment)
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer))
(key)
(integer))
(comment)
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer) (comment))
(key)
(integer)
(comment))
(comment)
(pair
(key) (integer)))
(key)
(integer)))
================================================================================
VALID - float - float with fractional or exponent or both
@ -392,21 +451,28 @@ flt7 = 6.626e-34
(document
(comment)
(pair
(key) (float))
(key)
(float))
(pair
(key) (float))
(key)
(float))
(pair
(key) (float))
(key)
(float))
(comment)
(pair
(key) (float))
(key)
(float))
(pair
(key) (float))
(key)
(float))
(pair
(key) (float))
(key)
(float))
(comment)
(pair
(key) (float)))
(key)
(float)))
================================================================================
VALID - float - float with underscores
@ -418,7 +484,8 @@ flt8 = 9_224_617.445_991_228_313
(document
(pair
(key) (float)))
(key)
(float)))
================================================================================
VALID - float - special float values
@ -439,18 +506,30 @@ sf6 = -nan # valid, actual encoding is implementation specific
(document
(comment)
(pair
(key) (float) (comment))
(key)
(float)
(comment))
(pair
(key) (float) (comment))
(key)
(float)
(comment))
(pair
(key) (float) (comment))
(key)
(float)
(comment))
(comment)
(pair
(key) (float) (comment))
(key)
(float)
(comment))
(pair
(key) (float) (comment))
(key)
(float)
(comment))
(pair
(key) (float) (comment)))
(key)
(float)
(comment)))
================================================================================
VALID - boolean - basic
@ -463,9 +542,11 @@ bool2 = false
(document
(pair
(key) (boolean))
(key)
(boolean))
(pair
(key) (boolean)))
(key)
(boolean)))
================================================================================
VALID - offset date time - basic
@ -479,11 +560,14 @@ odt3 = 1979-05-27T00:32:00.999999-07:00
(document
(pair
(key) (offset_date_time))
(key)
(offset_date_time))
(pair
(key) (offset_date_time))
(key)
(offset_date_time))
(pair
(key) (offset_date_time)))
(key)
(offset_date_time)))
================================================================================
VALID - offset date time - whitespace as delimiter
@ -495,7 +579,8 @@ odt4 = 1979-05-27 07:32:00Z
(document
(pair
(key) (offset_date_time)))
(key)
(offset_date_time)))
================================================================================
VALID - local date time - basic
@ -508,9 +593,11 @@ ldt2 = 1979-05-27T00:32:00.999999
(document
(pair
(key) (local_date_time))
(key)
(local_date_time))
(pair
(key) (local_date_time)))
(key)
(local_date_time)))
================================================================================
VALID - local date - basic
@ -522,7 +609,8 @@ ld1 = 1979-05-27
(document
(pair
(key) (local_date)))
(key)
(local_date)))
================================================================================
VALID - local time - basic
@ -535,9 +623,11 @@ lt2 = 00:32:00.999999
(document
(pair
(key) (local_time))
(key)
(local_time))
(pair
(key) (local_time)))
(key)
(local_time)))
================================================================================
VALID - array - basic (semantically INVALID for children with mixed types)
@ -557,33 +647,47 @@ arr6 = [ 1, 2.0 ] # INVALID
(pair
(key)
(array
(integer) (integer) (integer)))
(integer)
(integer)
(integer)))
(pair
(key)
(array
(string) (string) (string)))
(string)
(string)
(string)))
(pair
(key)
(array
(array
(integer) (integer))
(integer)
(integer))
(array
(integer) (integer) (integer))))
(integer)
(integer)
(integer))))
(pair
(key)
(array
(string) (string) (string) (string)))
(string)
(string)
(string)
(string)))
(pair
(key)
(array
(array
(integer) (integer))
(integer)
(integer))
(array
(string) (string) (string))))
(string)
(string)
(string))))
(pair
(key)
(array
(integer) (float))
(integer)
(float))
(comment)))
================================================================================
@ -605,11 +709,15 @@ arr8 = [
(pair
(key)
(array
(integer) (integer) (integer)))
(integer)
(integer)
(integer)))
(pair
(key)
(array
(integer) (integer) (comment))))
(integer)
(integer)
(comment))))
================================================================================
VALID - table - header
@ -641,15 +749,19 @@ key2 = 456
(table
(key)
(pair
(key) (string))
(key)
(string))
(pair
(key) (integer)))
(key)
(integer)))
(table
(key)
(pair
(key) (string))
(key)
(string))
(pair
(key) (integer))))
(key)
(integer))))
================================================================================
VALID - table - header with dotted key
@ -663,10 +775,12 @@ type.name = "pug"
(document
(table
(dotted_key
(key) (key))
(key)
(key))
(pair
(dotted_key
(key) (key))
(key)
(key))
(string))))
================================================================================
@ -684,25 +798,29 @@ VALID - table- header with whitespaces
(table
(dotted_key
(dotted_key
(key) (key))
(key)
(key))
(key))
(comment))
(table
(dotted_key
(dotted_key
(key) (key))
(key)
(key))
(key))
(comment))
(table
(dotted_key
(dotted_key
(key) (key))
(key)
(key))
(key))
(comment))
(table
(dotted_key
(dotted_key
(key) (key))
(key)
(key))
(key))
(comment)))
@ -725,7 +843,8 @@ VALID - table - directly defined nested header key
(dotted_key
(dotted_key
(dotted_key
(key) (key))
(key)
(key))
(key))
(key))
(comment)))
@ -749,11 +868,13 @@ c = 2
(table
(key)
(pair
(key) (integer)))
(key)
(integer)))
(table
(key)
(pair
(key) (integer))))
(key)
(integer))))
================================================================================
VALID - table - overlapped header key (semantically INVALID)
@ -774,12 +895,15 @@ c = 2
(table
(key)
(pair
(key) (integer)))
(key)
(integer)))
(table
(dotted_key
(key) (key))
(key)
(key))
(pair
(key) (integer))))
(key)
(integer))))
================================================================================
VALID - inline table - basic
@ -796,22 +920,27 @@ animal = { type.name = "pug" }
(key)
(inline_table
(pair
(key) (string))
(key)
(string))
(pair
(key) (string))))
(key)
(string))))
(pair
(key)
(inline_table
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (integer))))
(key)
(integer))))
(pair
(key)
(inline_table
(pair
(dotted_key
(key) (key))
(key)
(key))
(string)))))
================================================================================
@ -835,19 +964,24 @@ color = "gray"
(table_array_element
(key)
(pair
(key) (string))
(key)
(string))
(pair
(key) (integer)))
(key)
(integer)))
(table_array_element
(key))
(table_array_element
(key)
(pair
(key) (string))
(key)
(string))
(pair
(key) (integer))
(key)
(integer))
(pair
(key) (string))))
(key)
(string))))
================================================================================
VALID - array of tables - nested arrays of tables
@ -878,33 +1012,44 @@ VALID - array of tables - nested arrays of tables
(table_array_element
(key)
(pair
(key) (string)))
(key)
(string)))
(table
(dotted_key
(key) (key))
(key)
(key))
(pair
(key) (string))
(key)
(string))
(pair
(key) (string)))
(key)
(string)))
(table_array_element
(dotted_key
(key) (key))
(key)
(key))
(pair
(key) (string)))
(key)
(string)))
(table_array_element
(dotted_key
(key) (key))
(key)
(key))
(pair
(key) (string)))
(key)
(string)))
(table_array_element
(key)
(pair
(key) (string)))
(key)
(string)))
(table_array_element
(dotted_key
(key) (key))
(key)
(key))
(pair
(key) (string))))
(key)
(string))))
================================================================================
VALID - array of tables - append to statically defined array (semantically INVALID)
@ -920,9 +1065,11 @@ fruit = []
(document
(comment)
(pair
(key) (array))
(key)
(array))
(table_array_element
(key) (comment)))
(key)
(comment)))
================================================================================
VALID - array of tables - append to table (semantically INVALID)
@ -946,15 +1093,20 @@ VALID - array of tables - append to table (semantically INVALID)
(table_array_element
(key)
(pair
(key) (string)))
(key)
(string)))
(table_array_element
(dotted_key
(key) (key))
(key)
(key))
(pair
(key) (string))
(key)
(string))
(comment))
(table
(dotted_key
(key) (key))
(key)
(key))
(pair
(key) (string))))
(key)
(string))))

View file

@ -16,19 +16,17 @@
},
"license": "MIT",
"scripts": {
"lint": "prettier grammar.js --check",
"test": "tree-sitter test && tree-sitter parse examples/*.toml --quiet --time",
"prepack": "tree-sitter generate",
"release": "standard-version"
"test": "yarn tree-sitter test",
"prepack": "yarn tree-sitter generate",
"release": "standard-version",
"tree-sitter": "./tree-sitter/target/release/tree-sitter"
},
"dependencies": {
"nan": "^2.14.0"
},
"devDependencies": {
"prettier": "1.18.2",
"regexp-util": "1.2.2",
"standard-version": "7.0.0",
"tree-sitter-cli": "0.15.7"
"standard-version": "7.0.0"
},
"files": [
"/src/",

View file

@ -0,0 +1,40 @@
const generatePlayground = require("../tree-sitter/script/generate-playground");
generatePlayground("docs", {
name: "TOML",
example: `
# This is a TOML document.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates
[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8002 ]
connection_max = 5000
enabled = true
[servers]
# Indentation (tabs and/or spaces) is allowed but not required
[servers.alpha]
ip = "10.0.0.1"
dc = "eqdc10"
[servers.beta]
ip = "10.0.0.2"
dc = "eqdc10"
[clients]
data = [ ["gamma", "delta"], [1, 2] ]
# Line breaks are OK when inside arrays
hosts = [
"alpha",
"omega"
]
`.trim()
});

View file

@ -0,0 +1,5 @@
git clone https://github.com/ikatyang/tree-sitter --branch 0.15.9-custom --depth 1
cd tree-sitter
git submodule update --init
./script/build-wasm
cargo build --release

10
src/node-types.json generated
View file

@ -79,7 +79,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "dotted_key",
@ -138,7 +138,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "array",
@ -197,7 +197,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "escape_sequence",
@ -212,7 +212,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "dotted_key",
@ -235,7 +235,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "dotted_key",

3495
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -922,11 +922,6 @@ pinkie@^2.0.0:
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA=
prettier@1.18.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==
process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
@ -1231,11 +1226,6 @@ through@2, "through@>=2.2.7 <3":
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
tree-sitter-cli@0.15.7:
version "0.15.7"
resolved "https://registry.yarnpkg.com/tree-sitter-cli/-/tree-sitter-cli-0.15.7.tgz#3cda2910460243ad633c73c81460391ef7ec5798"
integrity sha512-6to6Hz4uOdmKd+Co4Y/nQps/u4pBG7oFKSmSVScJXtz+M76bFi1n9pB8s16Kdv55KJi4ur6pK4SGMfNdTKywsw==
trim-newlines@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"