tree-sitter-toml/corpus/custom.txt
Ika a3812033af
feat: flatten table/table-array structure (#2)
Input:

```toml
[table]
key = "value"
```

Output:

```sh
# before
(root
  (table
    (key)
    (pair (key) (string)))

# after
(root
  (table (key))
  (pair (key) (string)))
```
2019-08-20 14:59:19 +08:00

254 lines
5.1 KiB
Plaintext

================================================================================
VALID - empty file
================================================================================
--------------------------------------------------------------------------------
(root)
================================================================================
INVALID - key/value pair - multiline string for keys are not allowed
================================================================================
"""
invalid
multiline
basic
key
""" = false
'''
invalid
multiline
literal
key
''' = false
--------------------------------------------------------------------------------
(root
(pair
(key) (ERROR) (boolean)
)
(pair
(key) (ERROR) (boolean)
)
)
================================================================================
INVALID - float - whitespaces between its components are not allowed
================================================================================
invalid_fractional = 1 .0
invalid_exponent = 1 e 2
invalid_both = 1 .0 e 2
--------------------------------------------------------------------------------
(root
(ERROR
(dotted_key
(key) (ERROR) (key)
)
)
)
================================================================================
INVALID - offset date time - whitespaces between its components are not allowed
================================================================================
invalid1 = 1979-05-27 07:32:00 Z
invalid2 = 1979-05-27 T 07:32:00 Z
--------------------------------------------------------------------------------
(root
(ERROR
(key) (ERROR) (local_time) (local_time)
)
)
================================================================================
INVALID - local date time - whitespaces between its components are not allowed
================================================================================
invalid1 = 1979-05-27 07:32:00
invalid2 = 1979-05-27 T 07:32:00
--------------------------------------------------------------------------------
(root
(pair
(key) (ERROR) (local_time)
)
(pair
(key) (ERROR) (local_time)
)
)
================================================================================
INVALID - table - multiline string for header keys are not allowed
================================================================================
["""
invalid
multiline
basic
key
"""]
['''
invalid
multiline
basic
key
''']
--------------------------------------------------------------------------------
(root
(table
(key) (ERROR)
)
(table
(key) (ERROR)
)
)
================================================================================
INVALID - inline table - newlines outside of pairs are not allowed
================================================================================
key = {
newline = true
}
--------------------------------------------------------------------------------
(root
(pair
(key)
(inline_table
(ERROR)
(pair
(key) (boolean)
)
(ERROR)
)
)
)
================================================================================
INVALID - array of tables - multiline string for header keys are not allowed
================================================================================
[["""
invalid
multiline
basic
key
"""]]
[['''
invalid
multiline
basic
key
''']]
--------------------------------------------------------------------------------
(root
(ERROR
(key) (key)
)
)
================================================================================
VALID - table - empty content separated by comments
================================================================================
[table]
# comment
--------------------------------------------------------------------------------
(root
(table
(key)
)
(comment)
)
================================================================================
VALID - array of tables - empty content separated by comments
================================================================================
[[array-table]]
# comment
--------------------------------------------------------------------------------
(root
(table_array
(key)
)
(comment)
)
================================================================================
VALID - table - two pairs separated by comments
================================================================================
[table]
a = 1
# comment
b = 2
--------------------------------------------------------------------------------
(root
(table
(key)
)
(pair
(key) (integer)
)
(comment)
(pair
(key) (integer)
)
)
================================================================================
VALID - array of tables - two pairs separated by comments
================================================================================
[[array-table]]
a = 1
# comment
b = 2
--------------------------------------------------------------------------------
(root
(table_array
(key)
)
(pair
(key) (integer)
)
(comment)
(pair
(key) (integer)
)
)