srf-tree-sitter/test/corpus/long_format.txt
2026-09-01 10:07:02 -07:00

302 lines
4.6 KiB
Text

==================
Value containing commas
==================
#!srfv1
#!long
name::alice, bob and carol
cost:num:$1,000,000,000.42
---
(document
(magic)
(directive
(directive_long))
(field
(untyped_field
(key)
(value)))
(field
(typed_field
(key)
(type_hint)
(value))))
==================
Key containing a comma
==================
#!srfv1
#!long
last, first::alice
---
(document
(magic)
(directive
(directive_long))
(field
(untyped_field
(key)
(value))))
==================
Non-ASCII values
==================
#!srfv1
#!long
tokyo dinner:num:¥15,000
airbus:num:€410,000,000
---
(document
(magic)
(directive
(directive_long))
(field
(typed_field
(key)
(type_hint)
(value)))
(field
(typed_field
(key)
(type_hint)
(value))))
==================
Leading whitespace is insignificant
==================
#!srfv1
#!long
name::alice, bob
# indented comment
age:num:30
---
(document
(magic)
(directive
(directive_long))
(field
(untyped_field
(key)
(value)))
(comment)
(field
(typed_field
(key)
(type_hint)
(value))))
==================
Whitespace around the type hint
==================
#!srfv1
#!long
n: num : 5
m:num:6
---
(document
(magic)
(directive
(directive_long))
(field
(typed_field
(key)
(type_hint)
(value)))
(field
(typed_field
(key)
(type_hint)
(value))))
==================
Empty values
==================
#!srfv1
#!long
missing:null:
also missing::
name::alice
---
(document
(magic)
(directive
(directive_long))
(field
(typed_field
(key)
(type_hint)))
(field
(untyped_field
(key)))
(field
(untyped_field
(key)
(value))))
==================
Values that look like other syntax
==================
#!srfv1
#!long
url::https://x.example/a?b=1,c=2
note::alice # not an inline comment
shrug::,
---
(document
(magic)
(directive
(directive_long))
(field
(untyped_field
(key)
(value)))
(field
(untyped_field
(key)
(value)))
(field
(untyped_field
(key)
(value))))
==================
Records separated by blank lines
==================
#!srfv1
#!long
name::alice, of the alices
age:num:30
name::bob, of the bobs
age:num:25
---
(document
(magic)
(directive
(directive_long))
(field
(untyped_field
(key)
(value)))
(field
(typed_field
(key)
(type_hint)
(value)))
(blank_line)
(field
(untyped_field
(key)
(value)))
(field
(typed_field
(key)
(type_hint)
(value))))
==================
Long format from the SRF README
==================
#!srfv1 # mandatory comment with format and version. Parser instructions start with #!
#!requireeof # Set this if you want parsing to fail when #!eof not present on last line
#!long # Mandatory to use multiline records, compact format is optional #!compact
# A comment
# empty lines ignored
key::string value, with any data except a \n. an optional string length between the colons
this is a number:num: 5
null value:null:
array::array's don't exist. Use json or toml or something
data with newlines must have a length:7:foo
bar
boolean value:bool:false
# Empty line separates records, but comments don't count as empty
key::this is the second record
this is a number:num:42
null value:null:
array::array's still don't exist
data with newlines must have a length::single line
#!eof # eof marker, useful to make sure your file wasn't cut in half. Only considered if requireeof set at top
---
(document
(magic
(inline_comment))
(directive
(directive_requireeof
(inline_comment)))
(directive
(directive_long
(inline_comment)))
(comment)
(comment)
(blank_line)
(field
(untyped_field
(key)
(value)))
(field
(typed_field
(key)
(type_hint)
(value)))
(field
(typed_field
(key)
(type_hint)))
(field
(untyped_field
(key)
(value)))
(field
(typed_field
(key)
(type_hint)
(value)))
(field
(typed_field
(key)
(type_hint)
(value)))
(blank_line)
(comment)
(field
(untyped_field
(key)
(value)))
(field
(typed_field
(key)
(type_hint)
(value)))
(field
(typed_field
(key)
(type_hint)))
(field
(untyped_field
(key)
(value)))
(field
(untyped_field
(key)
(value)))
(directive
(directive_eof
(inline_comment))))