chore: update formatting

This commit is contained in:
Ika 2019-08-22 17:22:58 +08:00
parent 7edffec878
commit 000f53ee75
6 changed files with 221 additions and 486 deletions

View file

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

View file

@ -3,7 +3,7 @@
[![npm](https://img.shields.io/npm/v/tree-sitter-toml.svg)](https://www.npmjs.com/package/tree-sitter-toml) [![npm](https://img.shields.io/npm/v/tree-sitter-toml.svg)](https://www.npmjs.com/package/tree-sitter-toml)
[![build](https://img.shields.io/travis/com/ikatyang/tree-sitter-toml/master.svg)](https://travis-ci.com/ikatyang/tree-sitter-toml/builds) [![build](https://img.shields.io/travis/com/ikatyang/tree-sitter-toml/master.svg)](https://travis-ci.com/ikatyang/tree-sitter-toml/builds)
TOML ([spec v0.5.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md)) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter) TOML ([TOML Spec v0.5.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md)) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
[Changelog](https://github.com/ikatyang/tree-sitter-toml/blob/master/CHANGELOG.md) [Changelog](https://github.com/ikatyang/tree-sitter-toml/blob/master/CHANGELOG.md)

View file

@ -28,12 +28,9 @@ key
(file (file
(pair (pair
(key) (ERROR) (boolean) (key) (ERROR) (boolean))
)
(pair (pair
(key) (ERROR) (boolean) (key) (ERROR) (boolean)))
)
)
================================================================================ ================================================================================
INVALID - float - whitespaces between its components are not allowed INVALID - float - whitespaces between its components are not allowed
@ -48,10 +45,7 @@ invalid_both = 1 .0 e 2
(file (file
(ERROR (ERROR
(dotted_key (dotted_key
(key) (ERROR) (key) (key) (ERROR) (key))))
)
)
)
================================================================================ ================================================================================
INVALID - offset date time - whitespaces between its components are not allowed INVALID - offset date time - whitespaces between its components are not allowed
@ -64,9 +58,7 @@ invalid2 = 1979-05-27 T 07:32:00 Z
(file (file
(ERROR (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 INVALID - local date time - whitespaces between its components are not allowed
@ -79,9 +71,7 @@ invalid2 = 1979-05-27 T 07:32:00
(file (file
(ERROR (ERROR
(key) (local_date) (local_time) (local_time) (key) (local_date) (local_time) (local_time)))
)
)
================================================================================ ================================================================================
VALID - local date - trailing whitespaces are allowed VALID - local date - trailing whitespaces are allowed
@ -93,9 +83,7 @@ valid = 1979-05-27
(file (file
(pair (pair
(key) (local_date) (key) (local_date)))
)
)
================================================================================ ================================================================================
INVALID - table - multiline string for header keys are not allowed INVALID - table - multiline string for header keys are not allowed
@ -119,12 +107,9 @@ key
(file (file
(table (table
(key) (ERROR) (key) (ERROR))
)
(table (table
(key) (ERROR) (key) (ERROR)))
)
)
================================================================================ ================================================================================
INVALID - inline table - newlines outside of pairs are not allowed INVALID - inline table - newlines outside of pairs are not allowed
@ -142,12 +127,8 @@ key = {
(inline_table (inline_table
(ERROR) (ERROR)
(pair (pair
(key) (boolean) (key) (boolean))
) (ERROR))))
(ERROR)
)
)
)
================================================================================ ================================================================================
INVALID - array of tables - multiline string for header keys are not allowed INVALID - array of tables - multiline string for header keys are not allowed
@ -171,9 +152,7 @@ key
(file (file
(ERROR (ERROR
(key) (key) (key) (key)))
)
)
================================================================================ ================================================================================
VALID - table - empty content separated by comments VALID - table - empty content separated by comments
@ -187,10 +166,8 @@ VALID - table - empty content separated by comments
(file (file
(table (table
(key) (key))
) (comment))
(comment)
)
================================================================================ ================================================================================
VALID - array of tables - empty content separated by comments VALID - array of tables - empty content separated by comments
@ -204,10 +181,8 @@ VALID - array of tables - empty content separated by comments
(file (file
(table_array (table_array
(key) (key))
) (comment))
(comment)
)
================================================================================ ================================================================================
VALID - table - two pairs separated by comments VALID - table - two pairs separated by comments
@ -225,16 +200,12 @@ b = 2
(file (file
(table (table
(key) (key))
)
(pair (pair
(key) (integer) (key) (integer))
)
(comment) (comment)
(pair (pair
(key) (integer) (key) (integer)))
)
)
================================================================================ ================================================================================
VALID - array of tables - two pairs separated by comments VALID - array of tables - two pairs separated by comments
@ -252,13 +223,9 @@ b = 2
(file (file
(table_array (table_array
(key) (key))
)
(pair (pair
(key) (integer) (key) (integer))
)
(comment) (comment)
(pair (pair
(key) (integer) (key) (integer)))
)
)

View file

@ -10,9 +10,7 @@ key = "value" # This is a comment at the end of a line
(file (file
(comment) (comment)
(pair (pair
(key) (string) (comment) (key) (string) (comment)))
)
)
================================================================================ ================================================================================
VALID - key/value pair - basic VALID - key/value pair - basic
@ -24,9 +22,7 @@ key = "value"
(file (file
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
INVALID - key/value pair - empty value INVALID - key/value pair - empty value
@ -38,9 +34,7 @@ key = # INVALID
(file (file
(ERROR (ERROR
(key) (comment) (key) (comment)))
)
)
================================================================================ ================================================================================
VALID - keys - bare keys VALID - keys - bare keys
@ -55,18 +49,13 @@ bare-key = "value"
(file (file
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
VALID - keys - quoted keys VALID - keys - quoted keys
@ -82,21 +71,15 @@ VALID - keys - quoted keys
(file (file
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
INVALID - keys - empty bare key INVALID - keys - empty bare key
@ -111,18 +94,13 @@ INVALID - keys - empty bare key
(file (file
(pair (pair
(key (key
(MISSING _bare_key) (MISSING _bare_key))
)
(string) (string)
(comment) (comment))
)
(pair (pair
(key) (string) (comment) (key) (string) (comment))
)
(pair (pair
(key) (string) (comment) (key) (string) (comment)))
)
)
================================================================================ ================================================================================
VALID - keys - dotted keys VALID - keys - dotted keys
@ -137,27 +115,19 @@ site."google.com" = true
(file (file
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(dotted_key (dotted_key
(key) (key) (key) (key))
) (string))
(string)
)
(pair (pair
(dotted_key (dotted_key
(key) (key) (key) (key))
) (string))
(string)
)
(pair (pair
(dotted_key (dotted_key
(key) (key) (key) (key))
) (boolean)))
(boolean)
)
)
================================================================================ ================================================================================
VALID - keys - duplicate keys (semantically INVALID) VALID - keys - duplicate keys (semantically INVALID)
@ -172,12 +142,9 @@ name = "Pradyun"
(file (file
(comment) (comment)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
VALID - keys - directly defined nested keys VALID - keys - directly defined nested keys
@ -192,19 +159,13 @@ a.d = 2
(pair (pair
(dotted_key (dotted_key
(dotted_key (dotted_key
(key) (key) (key) (key))
) (key))
(key) (integer))
)
(integer)
)
(pair (pair
(dotted_key (dotted_key
(key) (key) (key) (key))
) (integer)))
(integer)
)
)
================================================================================ ================================================================================
VALID - keys - overlapped keys (semantically INVALID) VALID - keys - overlapped keys (semantically INVALID)
@ -220,20 +181,14 @@ a.b.c = 2
(comment) (comment)
(pair (pair
(dotted_key (dotted_key
(key) (key) (key) (key))
) (integer))
(integer)
)
(pair (pair
(dotted_key (dotted_key
(dotted_key (dotted_key
(key) (key) (key) (key))
) (key))
(key) (integer)))
)
(integer)
)
)
================================================================================ ================================================================================
VALID - string - basic strings VALID - string - basic strings
@ -247,10 +202,7 @@ str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
(pair (pair
(key) (key)
(string (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 VALID - string - multi-line basic strings
@ -264,9 +216,7 @@ Violets are blue"""
(file (file
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
VALID - string - multi-line basic strings with trailing backslashes VALID - string - multi-line basic strings with trailing backslashes
@ -293,21 +243,15 @@ str3 = """\
(file (file
(comment) (comment)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (key)
(string (string
(escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence)))
)
)
(pair (pair
(key) (key)
(string (string
(escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence))))
)
)
)
================================================================================ ================================================================================
VALID - string - literal strings VALID - string - literal strings
@ -324,18 +268,13 @@ regex = '<\i\c*\s*>'
(file (file
(comment) (comment)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
VALID - string - multi-line literal strings VALID - string - multi-line literal strings
@ -353,12 +292,9 @@ trimmed in raw strings.
(file (file
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
VALID - integer - signed/unsigned decimal integer VALID - integer - signed/unsigned decimal integer
@ -373,18 +309,13 @@ int4 = -17
(file (file
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (key) (integer)))
)
)
================================================================================ ================================================================================
VALID - integer - decimal integer with underscores VALID - integer - decimal integer with underscores
@ -398,15 +329,11 @@ int7 = 1_2_3_4_5 # VALID but discouraged
(file (file
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (comment) (key) (integer) (comment)))
)
)
================================================================================ ================================================================================
VALID - integer - hexadecimal/octal/binary integer VALID - integer - hexadecimal/octal/binary integer
@ -429,26 +356,19 @@ bin1 = 0b11010110
(file (file
(comment) (comment)
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (key) (integer))
)
(comment) (comment)
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (comment) (key) (integer) (comment))
)
(comment) (comment)
(pair (pair
(key) (integer) (key) (integer)))
)
)
================================================================================ ================================================================================
VALID - float - float with fractional or exponent or both VALID - float - float with fractional or exponent or both
@ -472,29 +392,21 @@ flt7 = 6.626e-34
(file (file
(comment) (comment)
(pair (pair
(key) (float) (key) (float))
)
(pair (pair
(key) (float) (key) (float))
)
(pair (pair
(key) (float) (key) (float))
)
(comment) (comment)
(pair (pair
(key) (float) (key) (float))
)
(pair (pair
(key) (float) (key) (float))
)
(pair (pair
(key) (float) (key) (float))
)
(comment) (comment)
(pair (pair
(key) (float) (key) (float)))
)
)
================================================================================ ================================================================================
VALID - float - float with underscores VALID - float - float with underscores
@ -506,9 +418,7 @@ flt8 = 9_224_617.445_991_228_313
(file (file
(pair (pair
(key) (float) (key) (float)))
)
)
================================================================================ ================================================================================
VALID - float - special float values VALID - float - special float values
@ -529,25 +439,18 @@ sf6 = -nan # valid, actual encoding is implementation specific
(file (file
(comment) (comment)
(pair (pair
(key) (float) (comment) (key) (float) (comment))
)
(pair (pair
(key) (float) (comment) (key) (float) (comment))
)
(pair (pair
(key) (float) (comment) (key) (float) (comment))
)
(comment) (comment)
(pair (pair
(key) (float) (comment) (key) (float) (comment))
)
(pair (pair
(key) (float) (comment) (key) (float) (comment))
)
(pair (pair
(key) (float) (comment) (key) (float) (comment)))
)
)
================================================================================ ================================================================================
VALID - boolean - basic VALID - boolean - basic
@ -560,12 +463,9 @@ bool2 = false
(file (file
(pair (pair
(key) (boolean) (key) (boolean))
)
(pair (pair
(key) (boolean) (key) (boolean)))
)
)
================================================================================ ================================================================================
VALID - offset date time - basic VALID - offset date time - basic
@ -579,15 +479,11 @@ odt3 = 1979-05-27T00:32:00.999999-07:00
(file (file
(pair (pair
(key) (offset_date_time) (key) (offset_date_time))
)
(pair (pair
(key) (offset_date_time) (key) (offset_date_time))
)
(pair (pair
(key) (offset_date_time) (key) (offset_date_time)))
)
)
================================================================================ ================================================================================
VALID - offset date time - whitespace as delimiter VALID - offset date time - whitespace as delimiter
@ -599,9 +495,7 @@ odt4 = 1979-05-27 07:32:00Z
(file (file
(pair (pair
(key) (offset_date_time) (key) (offset_date_time)))
)
)
================================================================================ ================================================================================
VALID - local date time - basic VALID - local date time - basic
@ -614,12 +508,9 @@ ldt2 = 1979-05-27T00:32:00.999999
(file (file
(pair (pair
(key) (local_date_time) (key) (local_date_time))
)
(pair (pair
(key) (local_date_time) (key) (local_date_time)))
)
)
================================================================================ ================================================================================
VALID - local date - basic VALID - local date - basic
@ -631,9 +522,7 @@ ld1 = 1979-05-27
(file (file
(pair (pair
(key) (local_date) (key) (local_date)))
)
)
================================================================================ ================================================================================
VALID - local time - basic VALID - local time - basic
@ -646,12 +535,9 @@ lt2 = 00:32:00.999999
(file (file
(pair (pair
(key) (local_time) (key) (local_time))
)
(pair (pair
(key) (local_time) (key) (local_time)))
)
)
================================================================================ ================================================================================
VALID - array - basic (semantically INVALID for children with mixed types) VALID - array - basic (semantically INVALID for children with mixed types)
@ -671,51 +557,34 @@ arr6 = [ 1, 2.0 ] # INVALID
(pair (pair
(key) (key)
(array (array
(integer) (integer) (integer) (integer) (integer) (integer)))
)
)
(pair (pair
(key) (key)
(array (array
(string) (string) (string) (string) (string) (string)))
)
)
(pair (pair
(key) (key)
(array (array
(array (array
(integer) (integer) (integer) (integer))
)
(array (array
(integer) (integer) (integer) (integer) (integer) (integer))))
)
)
)
(pair (pair
(key) (key)
(array (array
(string) (string) (string) (string) (string) (string) (string) (string)))
)
)
(pair (pair
(key) (key)
(array (array
(array (array
(integer) (integer) (integer) (integer))
)
(array (array
(string) (string) (string) (string) (string) (string))))
)
)
)
(pair (pair
(key) (key)
(array (array
(integer) (float) (integer) (float))
) (comment)))
(comment)
)
)
================================================================================ ================================================================================
VALID - array - allow newlines VALID - array - allow newlines
@ -736,16 +605,11 @@ arr8 = [
(pair (pair
(key) (key)
(array (array
(integer) (integer) (integer) (integer) (integer) (integer)))
)
)
(pair (pair
(key) (key)
(array (array
(integer) (integer) (comment) (integer) (integer) (comment))))
)
)
)
================================================================================ ================================================================================
VALID - table - header VALID - table - header
@ -757,9 +621,7 @@ VALID - table - header
(file (file
(table (table
(key) (key)))
)
)
================================================================================ ================================================================================
VALID - table - basic VALID - table - basic
@ -777,24 +639,17 @@ key2 = 456
(file (file
(table (table
(key) (key))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (integer) (key) (integer))
)
(table (table
(key) (key))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (integer) (key) (integer)))
)
)
================================================================================ ================================================================================
VALID - table - header with dotted key VALID - table - header with dotted key
@ -808,16 +663,11 @@ type.name = "pug"
(file (file
(table (table
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(dotted_key (dotted_key
(key) (key) (key) (key))
) (string)))
(string)
)
)
================================================================================ ================================================================================
VALID - table- header with whitespaces VALID - table- header with whitespaces
@ -834,40 +684,27 @@ VALID - table- header with whitespaces
(table (table
(dotted_key (dotted_key
(dotted_key (dotted_key
(key) (key) (key) (key))
) (key))
(key) (comment))
)
(comment)
)
(table (table
(dotted_key (dotted_key
(dotted_key (dotted_key
(key) (key) (key) (key))
) (key))
(key) (comment))
)
(comment)
)
(table (table
(dotted_key (dotted_key
(dotted_key (dotted_key
(key) (key) (key) (key))
) (key))
(key) (comment))
)
(comment)
)
(table (table
(dotted_key (dotted_key
(dotted_key (dotted_key
(key) (key) (key) (key))
) (key))
(key) (comment)))
)
(comment)
)
)
================================================================================ ================================================================================
VALID - table - directly defined nested header key VALID - table - directly defined nested header key
@ -888,15 +725,10 @@ VALID - table - directly defined nested header key
(dotted_key (dotted_key
(dotted_key (dotted_key
(dotted_key (dotted_key
(key) (key) (key) (key))
) (key))
(key) (key))
) (comment)))
(key)
)
(comment)
)
)
================================================================================ ================================================================================
VALID - table - duplicate header key (semantically INVALID) VALID - table - duplicate header key (semantically INVALID)
@ -915,18 +747,13 @@ c = 2
(file (file
(comment) (comment)
(table (table
(key) (key))
)
(pair (pair
(key) (integer) (key) (integer))
)
(table (table
(key) (key))
)
(pair (pair
(key) (integer) (key) (integer)))
)
)
================================================================================ ================================================================================
VALID - table - overlapped header key (semantically INVALID) VALID - table - overlapped header key (semantically INVALID)
@ -945,20 +772,14 @@ c = 2
(file (file
(comment) (comment)
(table (table
(key) (key))
)
(pair (pair
(key) (integer) (key) (integer))
)
(table (table
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(key) (integer) (key) (integer)))
)
)
================================================================================ ================================================================================
VALID - inline table - basic VALID - inline table - basic
@ -975,36 +796,23 @@ animal = { type.name = "pug" }
(key) (key)
(inline_table (inline_table
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))))
)
)
)
(pair (pair
(key) (key)
(inline_table (inline_table
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (integer) (key) (integer))))
)
)
)
(pair (pair
(key) (key)
(inline_table (inline_table
(pair (pair
(dotted_key (dotted_key
(key) (key) (key) (key))
) (string)))))
(string)
)
)
)
)
================================================================================ ================================================================================
VALID - array of tables - basic VALID - array of tables - basic
@ -1025,30 +833,21 @@ color = "gray"
(file (file
(table_array (table_array
(key) (key))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (integer) (key) (integer))
)
(table_array (table_array
(key) (key))
)
(table_array (table_array
(key) (key))
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (integer) (key) (integer))
)
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
VALID - array of tables - nested arrays of tables VALID - array of tables - nested arrays of tables
@ -1077,53 +876,35 @@ VALID - array of tables - nested arrays of tables
(file (file
(table_array (table_array
(key) (key))
)
(pair (pair
(key) (string) (key) (string))
)
(table (table
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(key) (string) (key) (string))
)
(pair (pair
(key) (string) (key) (string))
)
(table_array (table_array
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(key) (string) (key) (string))
)
(table_array (table_array
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(key) (string) (key) (string))
)
(table_array (table_array
(key) (key))
)
(pair (pair
(key) (string) (key) (string))
)
(table_array (table_array
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(key) (string) (key) (string)))
)
)
================================================================================ ================================================================================
VALID - array of tables - append to statically defined array (semantically INVALID) VALID - array of tables - append to statically defined array (semantically INVALID)
@ -1139,12 +920,9 @@ fruit = []
(file (file
(comment) (comment)
(pair (pair
(key) (array) (key) (array))
)
(table_array (table_array
(key) (comment) (key) (comment)))
)
)
================================================================================ ================================================================================
VALID - array of tables - append to table (semantically INVALID) VALID - array of tables - append to table (semantically INVALID)
@ -1166,26 +944,17 @@ VALID - array of tables - append to table (semantically INVALID)
(file (file
(comment) (comment)
(table_array (table_array
(key) (key))
)
(pair (pair
(key) (string) (key) (string))
)
(table_array (table_array
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(key) (string) (key) (string))
)
(comment) (comment)
(table (table
(dotted_key (dotted_key
(key) (key) (key) (key)))
)
)
(pair (pair
(key) (string) (key) (string)))
)
)

View file

@ -58,7 +58,7 @@ module.exports = grammar({
$.local_date, $.local_date,
$.local_time, $.local_time,
$.array, $.array,
$.inline_table $.inline_table,
), ),
string: $ => string: $ =>
@ -66,7 +66,7 @@ module.exports = grammar({
$._basic_string, $._basic_string,
$._multiline_basic_string, $._multiline_basic_string,
$._literal_string, $._literal_string,
$._multiline_literal_string $._multiline_literal_string,
), ),
_basic_string: $ => _basic_string: $ =>
seq( seq(
@ -74,12 +74,12 @@ module.exports = grammar({
repeat( repeat(
choice( choice(
token.immediate( token.immediate(
repeat1(getInverseRegex(control_chars.union('"', "\\"))) repeat1(getInverseRegex(control_chars.union('"', "\\"))),
), ),
$.escape_sequence $.escape_sequence,
) ),
), ),
token.immediate('"') token.immediate('"'),
), ),
_multiline_basic_string: $ => _multiline_basic_string: $ =>
seq( seq(
@ -87,19 +87,19 @@ module.exports = grammar({
repeat( repeat(
choice( choice(
token.immediate( token.immediate(
repeat1(getInverseRegex(control_chars.union('"', "\\"))) repeat1(getInverseRegex(control_chars.union('"', "\\"))),
), ),
token.immediate(/"{1,2}/), token.immediate(/"{1,2}/),
token.immediate(newline), token.immediate(newline),
$.escape_sequence, $.escape_sequence,
alias($._escape_line_ending, $.escape_sequence) alias($._escape_line_ending, $.escape_sequence),
) ),
), ),
token.immediate('"""') token.immediate('"""'),
), ),
escape_sequence: $ => escape_sequence: $ =>
token.immediate( token.immediate(
seq("\\", choice(/[btnfr"\\]/, /u[0-9a-fA-F]{4}/, /U[0-9a-fA-F]{8}/)) seq("\\", choice(/[btnfr"\\]/, /u[0-9a-fA-F]{4}/, /U[0-9a-fA-F]{8}/)),
), ),
_escape_line_ending: $ => token.immediate(seq("\\", /\r?\n/)), _escape_line_ending: $ => token.immediate(seq("\\", /\r?\n/)),
_literal_string: $ => _literal_string: $ =>
@ -107,10 +107,10 @@ module.exports = grammar({
"'", "'",
optional( optional(
token.immediate( token.immediate(
repeat1(getInverseRegex(control_chars.union("'").subtract("\t"))) repeat1(getInverseRegex(control_chars.union("'").subtract("\t"))),
) ),
), ),
token.immediate("'") token.immediate("'"),
), ),
_multiline_literal_string: $ => _multiline_literal_string: $ =>
seq( seq(
@ -118,13 +118,13 @@ module.exports = grammar({
repeat( repeat(
choice( choice(
token.immediate( token.immediate(
repeat1(getInverseRegex(control_chars.union("'").subtract("\t"))) repeat1(getInverseRegex(control_chars.union("'").subtract("\t"))),
), ),
token.immediate(/'{1,2}/), token.immediate(/'{1,2}/),
token.immediate(newline) token.immediate(newline),
) ),
), ),
token.immediate("'''") token.immediate("'''"),
), ),
integer: $ => integer: $ =>
@ -132,7 +132,7 @@ module.exports = grammar({
decimal_integer, decimal_integer,
hexadecimal_integer, hexadecimal_integer,
octal_integer, octal_integer,
binary_integer binary_integer,
), ),
float: $ => float: $ =>
@ -142,12 +142,12 @@ module.exports = grammar({
choice( choice(
seq( seq(
token.immediate(float_fractional_part), token.immediate(float_fractional_part),
optional(token.immediate(float_exponent_part)) optional(token.immediate(float_exponent_part)),
), ),
token.immediate(float_exponent_part) token.immediate(float_exponent_part),
) ),
), ),
/[+-]?(inf|nan)/ /[+-]?(inf|nan)/,
), ),
boolean: $ => /true|false/, boolean: $ => /true|false/,
@ -157,7 +157,7 @@ module.exports = grammar({
rfc3339_date, rfc3339_date,
rfc3339_delimiter, rfc3339_delimiter,
rfc3339_time, rfc3339_time,
rfc3339_offset rfc3339_offset,
), ),
local_date_time: $ => local_date_time: $ =>
concatRegex(rfc3339_date, rfc3339_delimiter, rfc3339_time), concatRegex(rfc3339_date, rfc3339_delimiter, rfc3339_time),
@ -173,12 +173,12 @@ module.exports = grammar({
$._inline_value, $._inline_value,
repeat($._newline), repeat($._newline),
repeat( repeat(
seq(",", repeat($._newline), $._inline_value, repeat($._newline)) seq(",", repeat($._newline), $._inline_value, repeat($._newline)),
), ),
optional(seq(",", repeat($._newline))) optional(seq(",", repeat($._newline))),
) ),
), ),
"]" "]",
), ),
inline_table: $ => inline_table: $ =>
@ -187,10 +187,10 @@ module.exports = grammar({
optional( optional(
seq( seq(
alias($._inline_pair, $.pair), alias($._inline_pair, $.pair),
repeat(seq(",", alias($._inline_pair, $.pair))) repeat(seq(",", alias($._inline_pair, $.pair))),
) ),
), ),
"}" "}",
), ),
}, },
}); });

View file

@ -5,10 +5,9 @@ enum TokenType {
}; };
void *tree_sitter_toml_external_scanner_create() { return NULL; } void *tree_sitter_toml_external_scanner_create() { return NULL; }
void tree_sitter_toml_external_scanner_destroy(void *p) {} void tree_sitter_toml_external_scanner_destroy(void *payload) {}
void tree_sitter_toml_external_scanner_reset(void *p) {} unsigned tree_sitter_toml_external_scanner_serialize(void *payload, char *buffer) { return 0; }
unsigned tree_sitter_toml_external_scanner_serialize(void *p, char *buffer) { return 0; } void tree_sitter_toml_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {}
void tree_sitter_toml_external_scanner_deserialize(void *p, const char *b, unsigned n) {}
bool tree_sitter_toml_external_scanner_scan( bool tree_sitter_toml_external_scanner_scan(
void *payload, void *payload,