├── spec-tests ├── tests │ ├── valid │ │ ├── empty-file.toml │ │ ├── comment │ │ │ ├── noeol.json │ │ │ ├── noeol.toml │ │ │ ├── at-eof.json │ │ │ ├── at-eof2.json │ │ │ ├── at-eof.toml │ │ │ ├── at-eof2.toml │ │ │ ├── everywhere.json │ │ │ ├── tricky.toml │ │ │ └── everywhere.toml │ │ ├── empty-file.json │ │ ├── table │ │ │ ├── empty.toml │ │ │ ├── no-eol.toml │ │ │ ├── sub-empty.toml │ │ │ ├── whitespace.toml │ │ │ ├── empty.json │ │ │ ├── no-eol.json │ │ │ ├── whitespace.json │ │ │ ├── with-pound.toml │ │ │ ├── array-implicit.toml │ │ │ ├── sub-empty.json │ │ │ ├── with-single-quotes.toml │ │ │ ├── array-one.toml │ │ │ ├── with-literal-string.toml │ │ │ ├── keyword.json │ │ │ ├── keyword.toml │ │ │ ├── with-pound.json │ │ │ ├── without-super.json │ │ │ ├── names.toml │ │ │ ├── array-table-array.toml │ │ │ ├── without-super.toml │ │ │ ├── with-single-quotes.json │ │ │ ├── array-implicit.json │ │ │ ├── with-literal-string.json │ │ │ ├── array-many.toml │ │ │ ├── array-one.json │ │ │ ├── array-nest.toml │ │ │ ├── names.json │ │ │ ├── array-table-array.json │ │ │ ├── array-many.json │ │ │ └── array-nest.json │ │ ├── key │ │ │ ├── numeric.toml │ │ │ ├── space.toml │ │ │ ├── empty.toml │ │ │ ├── numeric-dotted.toml │ │ │ ├── equals-nospace.toml │ │ │ ├── special-chars.toml │ │ │ ├── empty.json │ │ │ ├── numeric.json │ │ │ ├── space.json │ │ │ ├── equals-nospace.json │ │ │ ├── special-word.toml │ │ │ ├── numeric-dotted.json │ │ │ ├── special-chars.json │ │ │ ├── quoted-dots.toml │ │ │ ├── escapes.toml │ │ │ ├── alphanum.toml │ │ │ ├── case-sensitive.toml │ │ │ ├── special-word.json │ │ │ ├── escapes.json │ │ │ ├── quoted-dots.json │ │ │ ├── dotted.toml │ │ │ ├── case-sensitive.json │ │ │ └── alphanum.json │ │ ├── string │ │ │ ├── empty.toml │ │ │ ├── unicode-literal.toml │ │ │ ├── escaped-escape.toml │ │ │ ├── double-quote-escape.toml │ │ │ ├── simple.toml │ │ │ ├── unicode-escape.toml │ │ │ ├── empty.json │ │ │ ├── escaped-escape.json │ │ │ ├── unicode-literal.json │ │ │ ├── double-quote-escape.json │ │ │ ├── simple.json │ │ │ ├── with-pound.toml │ │ │ ├── nl.toml │ │ │ ├── unicode-escape.json │ │ │ ├── with-pound.json │ │ │ ├── raw-multiline.json │ │ │ ├── raw.toml │ │ │ ├── escape-tricky.toml │ │ │ ├── raw-multiline.toml │ │ │ ├── nl.json │ │ │ ├── multiline-quotes.toml │ │ │ ├── escape-tricky.json │ │ │ ├── escapes.toml │ │ │ ├── raw.json │ │ │ ├── multiline-quotes.json │ │ │ ├── multiline.toml │ │ │ ├── multiline.json │ │ │ └── escapes.json │ │ ├── array │ │ │ ├── bool.toml │ │ │ ├── nospaces.toml │ │ │ ├── empty.toml │ │ │ ├── nested.toml │ │ │ ├── nested-inline-table.toml │ │ │ ├── string-quote-comma-2.toml │ │ │ ├── mixed-int-float.toml │ │ │ ├── mixed-int-string.toml │ │ │ ├── hetergeneous.toml │ │ │ ├── table-array-string-backslash.toml │ │ │ ├── mixed-int-array.toml │ │ │ ├── nested-double.toml │ │ │ ├── strings.toml │ │ │ ├── string-with-comma.toml │ │ │ ├── nested-inline-table.json │ │ │ ├── string-quote-comma.toml │ │ │ ├── string-quote-comma-2.json │ │ │ ├── empty.json │ │ │ ├── mixed-string-table.toml │ │ │ ├── table-array-string-backslash.json │ │ │ ├── bool.json │ │ │ ├── mixed-int-float.json │ │ │ ├── mixed-int-string.json │ │ │ ├── string-with-comma.json │ │ │ ├── string-quote-comma.json │ │ │ ├── nested.json │ │ │ ├── array.toml │ │ │ ├── mixed-int-array.json │ │ │ ├── nospaces.json │ │ │ ├── strings.json │ │ │ ├── mixed-string-table.json │ │ │ ├── nested-double.json │ │ │ ├── hetergeneous.json │ │ │ └── array.json │ │ ├── bool │ │ │ ├── bool.toml │ │ │ └── bool.json │ │ ├── implicit-groups.toml │ │ ├── newline-lf.toml │ │ ├── datetime │ │ │ ├── local-date.toml │ │ │ ├── local-time.toml │ │ │ ├── datetime.toml │ │ │ ├── local.toml │ │ │ ├── local-date.json │ │ │ ├── timezone.toml │ │ │ ├── milliseconds.toml │ │ │ ├── datetime.json │ │ │ ├── local-time.json │ │ │ ├── local.json │ │ │ ├── timezone.json │ │ │ └── milliseconds.json │ │ ├── inline-table │ │ │ ├── bool.toml │ │ │ ├── end-in-bool.toml │ │ │ ├── multiline.toml │ │ │ ├── array.toml │ │ │ ├── empty.toml │ │ │ ├── inline-table.toml │ │ │ ├── bool.json │ │ │ ├── end-in-bool.json │ │ │ ├── multiline.json │ │ │ ├── nest.toml │ │ │ ├── key-dotted.toml │ │ │ ├── empty.json │ │ │ ├── array.json │ │ │ ├── inline-table.json │ │ │ └── nest.json │ │ ├── newline-crlf.toml │ │ ├── integer │ │ │ ├── underscore.toml │ │ │ ├── integer.toml │ │ │ ├── long.toml │ │ │ ├── underscore.json │ │ │ ├── zero.toml │ │ │ ├── literals.toml │ │ │ ├── long.json │ │ │ ├── integer.json │ │ │ ├── literals.json │ │ │ └── zero.json │ │ ├── float │ │ │ ├── long.toml │ │ │ ├── underscore.toml │ │ │ ├── float.toml │ │ │ ├── exponent.toml │ │ │ ├── zero.toml │ │ │ ├── long.json │ │ │ ├── inf-and-nan.toml │ │ │ ├── underscore.json │ │ │ ├── float.json │ │ │ ├── inf-and-nan.json │ │ │ ├── zero.json │ │ │ └── exponent.json │ │ ├── implicit-and-explicit-after.toml │ │ ├── implicit-and-explicit-before.toml │ │ ├── example.toml │ │ ├── newline-crlf.json │ │ ├── newline-lf.json │ │ ├── implicit-groups.json │ │ ├── implicit-and-explicit-after.json │ │ ├── implicit-and-explicit-before.json │ │ ├── spec-example-1-compact.toml │ │ ├── example.json │ │ └── spec-example-1.toml │ └── invalid │ │ ├── key │ │ ├── empty.toml │ │ ├── hash.toml │ │ ├── space.toml │ │ ├── no-eol.toml │ │ ├── two-equals.toml │ │ ├── two-equals2.toml │ │ ├── two-equals3.toml │ │ ├── without-value-1.toml │ │ ├── open-bracket.toml │ │ ├── single-open-bracket.toml │ │ ├── without-value-2.toml │ │ ├── newline.toml │ │ ├── multiline.toml │ │ ├── partial-quoted.toml │ │ ├── bare-invalid-character.toml │ │ ├── start-bracket.toml │ │ ├── after-array.toml │ │ ├── duplicate-keys.toml │ │ ├── special-character.toml │ │ ├── after-table.toml │ │ ├── escape.toml │ │ ├── after-value.toml │ │ ├── duplicate.toml │ │ └── dotted-redefine-table.toml │ │ ├── table │ │ ├── empty.toml │ │ ├── llbrace.toml │ │ ├── rrbrace.toml │ │ ├── equals-sign.toml │ │ ├── whitespace.toml │ │ ├── with-pound.toml │ │ ├── array-empty.toml │ │ ├── duplicate-table-array.toml │ │ ├── duplicate-table-array2.toml │ │ ├── empty-implicit-table.toml │ │ ├── nested-brackets-close.toml │ │ ├── nested-brackets-open.toml │ │ ├── duplicate.toml │ │ ├── text-after-table.toml │ │ ├── quoted-no-close.toml │ │ ├── array-missing-bracket.toml │ │ ├── duplicate-key-table.toml │ │ ├── redefine.toml │ │ ├── append-with-dotted-keys-2.toml │ │ ├── append-with-dotted-keys-1.toml │ │ └── array-implicit.toml │ │ ├── array │ │ ├── no-close-2.toml │ │ ├── no-close-table.toml │ │ ├── no-close.toml │ │ ├── missing-separator.toml │ │ ├── no-close-table-2.toml │ │ ├── tables-1.toml │ │ ├── text-in-array.toml │ │ ├── text-after-array-entries.toml │ │ ├── text-before-array-separator.toml │ │ └── tables-2.toml │ │ ├── bool │ │ ├── mixed-case.toml │ │ ├── wrong-case-true.toml │ │ └── wrong-case-false.toml │ │ ├── inline-table │ │ ├── empty.toml │ │ ├── no-comma.toml │ │ ├── double-comma.toml │ │ ├── linebreak-2.toml │ │ ├── linebreak-3.toml │ │ ├── duplicate-key.toml │ │ ├── linebreak-4.toml │ │ ├── overwrite.toml │ │ ├── linebreak-1.toml │ │ └── trailing-comma.toml │ │ ├── float │ │ ├── leading-us.toml │ │ ├── exp-point-1.toml │ │ ├── exp-point-2.toml │ │ ├── leading-zero.toml │ │ ├── trailing-us.toml │ │ ├── double-point-1.toml │ │ ├── double-point-2.toml │ │ ├── exp-double-e-1.toml │ │ ├── exp-double-e-2.toml │ │ ├── exp-double-us.toml │ │ ├── exp-leading-us.toml │ │ ├── inf-incomplete-1.toml │ │ ├── inf_underscore.toml │ │ ├── leading-point.toml │ │ ├── nan-incomplete-1.toml │ │ ├── nan_underscore.toml │ │ ├── trailing-point.toml │ │ ├── us-after-point.toml │ │ ├── us-before-point.toml │ │ ├── exp-trailing-us.toml │ │ ├── inf-incomplete-2.toml │ │ ├── inf-incomplete-3.toml │ │ ├── leading-zero-neg.toml │ │ ├── nan-incomplete-2.toml │ │ ├── nan-incomplete-3.toml │ │ ├── trailing-point-min.toml │ │ ├── leading-point-neg.toml │ │ ├── leading-point-plus.toml │ │ ├── leading-zero-plus.toml │ │ ├── trailing-point-plus.toml │ │ ├── trailing-us-exp.toml │ │ └── float.multi │ │ ├── string │ │ ├── bad-uni-esc.toml │ │ ├── missing-quotes.toml │ │ ├── multiline-no-close-2.toml │ │ ├── bad-byte-escape.toml │ │ ├── basic-unknown-escape.toml │ │ ├── basic-byte-escapes.toml │ │ ├── bad-concat.toml │ │ ├── multiline-bad-escape-1.toml │ │ ├── multiline-quotes-1.toml │ │ ├── multiline-quotes-2.toml │ │ ├── basic-multiline-unknown-escape.toml │ │ ├── bad-multiline.toml │ │ ├── basic-out-of-range-unicode-escape-1.toml │ │ ├── basic-out-of-range-unicode-escape-2.toml │ │ ├── no-close.toml │ │ ├── wrong-close.toml │ │ ├── multiline-no-close.toml │ │ ├── literal-multiline-quotes-1.toml │ │ ├── multiline-escape-space.toml │ │ ├── text-after-string.toml │ │ ├── basic-multiline-out-of-range-unicode-escape-1.toml │ │ ├── basic-multiline-out-of-range-unicode-escape-2.toml │ │ ├── basic-multiline-quotes.toml │ │ ├── literal-multiline-quotes-2.toml │ │ ├── bad-escape-1.toml │ │ ├── multiline-bad-escape-2.toml │ │ ├── bad-escape-2.toml │ │ ├── bad-slash-escape.toml │ │ ├── multiline-bad-escape-3.toml │ │ └── bad-codepoint.toml │ │ ├── control │ │ ├── multi-lf.toml │ │ ├── multi-us.toml │ │ ├── string-del.toml │ │ ├── string-lf.toml │ │ ├── string-us.toml │ │ ├── bare-null.toml │ │ ├── comment-del.toml │ │ ├── comment-lf.toml │ │ ├── comment-us.toml │ │ ├── multi-del.toml │ │ ├── multi-null.toml │ │ ├── rawstring-lf.toml │ │ ├── rawstring-us.toml │ │ ├── string-bs.toml │ │ ├── string-null.toml │ │ ├── comment-null.toml │ │ ├── rawmulti-del.toml │ │ ├── rawmulti-lf.toml │ │ ├── rawmulti-null.toml │ │ ├── rawmulti-us.toml │ │ ├── rawstring-del.toml │ │ ├── rawstring-null.toml │ │ ├── comment-cr.toml │ │ └── control.multi │ │ ├── integer │ │ ├── capital-bin.toml │ │ ├── capital-hex.toml │ │ ├── capital-oct.toml │ │ ├── double-us.toml │ │ ├── invalid-oct.toml │ │ ├── leading-us.toml │ │ ├── trailing-us.toml │ │ ├── invalid-bin.toml │ │ ├── invalid-hex.toml │ │ ├── leading-us-bin.toml │ │ ├── leading-us-hex.toml │ │ ├── leading-us-oct.toml │ │ ├── leading-zero-1.toml │ │ ├── leading-zero-2.toml │ │ ├── leading-zero-3.toml │ │ ├── negative-hex.toml │ │ ├── negative-oct.toml │ │ ├── positive-hex.toml │ │ ├── positive-oct.toml │ │ ├── us-after-bin.toml │ │ ├── us-after-hex.toml │ │ ├── us-after-oct.toml │ │ ├── double-sign-nex.toml │ │ ├── double-sign-plus.toml │ │ ├── negative-bin.toml │ │ ├── positive-bin.toml │ │ ├── trailing-us-bin.toml │ │ ├── trailing-us-hex.toml │ │ ├── trailing-us-oct.toml │ │ ├── leading-zero-sign-1.toml │ │ ├── leading-zero-sign-2.toml │ │ ├── leading-zero-sign-3.toml │ │ ├── text-after-integer.toml │ │ └── integer.multi │ │ ├── encoding │ │ ├── utf16.toml │ │ ├── utf16-bom.toml │ │ ├── bad-utf8-at-end.toml │ │ ├── bad-utf8-in-comment.toml │ │ ├── bad-utf8-in-string.toml │ │ ├── bom-not-at-start-1.toml │ │ └── bom-not-at-start-2.toml │ │ └── datetime │ │ ├── no-secs.toml │ │ ├── time-no-leads-2.toml │ │ ├── time-no-leads.toml │ │ ├── trailing-t.toml │ │ ├── hour-over.toml │ │ ├── month-over.toml │ │ ├── no-t.toml │ │ ├── minute-over.toml │ │ ├── month-under.toml │ │ ├── no-leads.toml │ │ ├── no-leads-with-milli.toml │ │ ├── mday-over.toml │ │ ├── mday-under.toml │ │ └── second-over.toml ├── errors │ ├── bare-key-3.toml │ ├── bare-key-1.toml │ ├── int-0-padded.toml │ ├── int-signed-bin.toml │ ├── int-signed-hex.toml │ ├── int-signed-oct.toml │ ├── bare-key-2.toml │ ├── comment-control-1.toml │ ├── comment-control-2.toml │ ├── comment-control-3.toml │ ├── comment-control-4.toml │ ├── key-value-pair-1.toml │ ├── string-basic-control-1.toml │ ├── string-basic-control-2.toml │ ├── string-basic-control-3.toml │ ├── string-basic-control-4.toml │ ├── string-basic-unknown-escape.toml │ ├── string-literal-control-1.toml │ ├── string-literal-control-2.toml │ ├── string-literal-control-3.toml │ ├── string-literal-control-4.toml │ ├── no-key-name.toml │ ├── inline-table-trailing-comma.toml │ ├── string-basic-multiline-control-1.toml │ ├── string-basic-multiline-control-2.toml │ ├── string-basic-multiline-control-3.toml │ ├── string-basic-multiline-control-4.toml │ ├── string-basic-multiline-unknown-escape.toml │ ├── string-literal-multiline-control-1.toml │ ├── string-literal-multiline-control-2.toml │ ├── string-literal-multiline-control-3.toml │ ├── string-literal-multiline-control-4.toml │ ├── string-basic-out-of-range-unicode-escape-1.toml │ ├── string-basic-out-of-range-unicode-escape-2.toml │ ├── key-value-pair-2.toml │ ├── multiple-key.toml │ ├── string-basic-multiline-invalid-backslash.toml │ ├── string-basic-multiline-out-of-range-unicode-escape-1.toml │ ├── string-basic-multiline-out-of-range-unicode-escape-2.toml │ ├── string-basic-multiline-quotes.toml │ ├── array-of-tables-1.toml │ ├── table-invalid-2.toml │ ├── inline-table-imutable-1.toml │ ├── inline-table-imutable-2.toml │ ├── table-1.toml │ ├── string-literal-multiline-quotes.toml │ ├── table-3.toml │ ├── table-4.toml │ ├── table-2.toml │ ├── array-of-tables-2.toml │ ├── multiple-dot-key.toml │ ├── table-invalid-1.toml │ ├── table-invalid-4.toml │ └── table-invalid-3.toml └── values │ ├── spec-int-1.toml │ ├── spec-int-1.yaml │ ├── spec-int-2.toml │ ├── spec-int-2.yaml │ ├── spec-int-3.toml │ ├── spec-int-3.yaml │ ├── spec-int-3a.toml │ ├── spec-int-3a.yaml │ ├── spec-int-3b.toml │ ├── spec-int-3b.yaml │ ├── spec-int-4.toml │ ├── spec-int-4.yaml │ ├── spec-table-3.toml │ ├── spec-table.toml │ ├── spec-table.yaml │ ├── spec-boolean-1.yaml │ ├── spec-float-1.toml │ ├── spec-float-1.yaml │ ├── spec-float-14.yaml │ ├── spec-float-15.yaml │ ├── spec-float-2.toml │ ├── spec-float-2.yaml │ ├── spec-float-3.toml │ ├── spec-float-3.yaml │ ├── spec-float-4.toml │ ├── spec-float-4.yaml │ ├── spec-float-5.toml │ ├── spec-float-5.yaml │ ├── spec-float-6.toml │ ├── spec-float-6.yaml │ ├── spec-float-9.toml │ ├── spec-float-9.yaml │ ├── spec-int-5.toml │ ├── spec-int-5.yaml │ ├── spec-int-6.yaml │ ├── spec-int-bin1.yaml │ ├── spec-int-oct1.yaml │ ├── spec-int-oct2.yaml │ ├── spec-key-value-pair-6.toml │ ├── spec-key-value-pair-6.yaml │ ├── spec-key-value-pair-7.toml │ ├── spec-key-value-pair-7.yaml │ ├── spec-time-1.toml │ ├── spec-boolean-1.toml │ ├── spec-boolean-2.toml │ ├── spec-boolean-2.yaml │ ├── spec-comment-tab.yaml │ ├── spec-dotted-keys-2.toml │ ├── spec-float-7.toml │ ├── spec-float-7.yaml │ ├── spec-int-6.toml │ ├── spec-int-bin1.toml │ ├── spec-int-hex1.toml │ ├── spec-int-hex1.yaml │ ├── spec-int-hex2.toml │ ├── spec-int-hex2.yaml │ ├── spec-int-hex3.yaml │ ├── spec-int-oct1.toml │ ├── spec-key-value-pair-8.yaml │ ├── spec-string-escape-1.toml │ ├── spec-string-escape-1.yaml │ ├── spec-string-escape-2.toml │ ├── spec-string-escape-2.yaml │ ├── spec-string-escape-3.toml │ ├── spec-string-escape-3.yaml │ ├── spec-string-escape-4.toml │ ├── spec-string-escape-4.yaml │ ├── spec-string-escape-5.toml │ ├── spec-string-escape-5.yaml │ ├── spec-string-escape-6.toml │ ├── spec-string-escape-6.yaml │ ├── spec-string-escape-7.toml │ ├── spec-string-escape-7.yaml │ ├── spec-string-escape-8.yaml │ ├── spec-string-escape-9.yaml │ ├── spec-array-1.toml │ ├── spec-array-1.yaml │ ├── spec-date-local-1.toml │ ├── spec-dotted-keys-2.yaml │ ├── spec-dotted-keys-3.toml │ ├── spec-dotted-keys-3.yaml │ ├── spec-empty-key-name-1.yaml │ ├── spec-empty-key-name-2.yaml │ ├── spec-float-8.yaml │ ├── spec-int-hex3.toml │ ├── spec-key-value-pair-1.toml │ ├── spec-key-value-pair-1.yaml │ ├── spec-key-value-pair-4.toml │ ├── spec-key-value-pair-5.toml │ ├── spec-key-value-pair-8.toml │ ├── spec-key-value-pair-9.toml │ ├── spec-newline-1.yaml │ ├── spec-newline-2.yaml │ ├── spec-string-escape-8.toml │ ├── spec-time-2.toml │ ├── spec-case-sensitive.yaml │ ├── spec-float-14.toml │ ├── spec-float-8.toml │ ├── spec-key-value-pair-2.toml │ ├── spec-key-value-pair-2.yaml │ ├── spec-key-value-pair-3.toml │ ├── spec-key-value-pair-3.yaml │ ├── spec-key-value-pair-4.yaml │ ├── spec-key-value-pair-5.yaml │ ├── spec-newline-1.toml │ ├── spec-newline-2.toml │ ├── spec-quoted-basic-keys-1.toml │ ├── spec-quoted-basic-keys-1.yaml │ ├── spec-string-basic-multiline-4.yaml │ ├── spec-string-escape-9.toml │ ├── spec-string-literal-4.yaml │ ├── spec-table-3.yaml │ ├── spec-table-4.yaml │ ├── spec-table-5.yaml │ ├── spec-table-6.yaml │ ├── spec-array-7.toml │ ├── spec-array-7.yaml │ ├── spec-date-time-1.toml │ ├── spec-date-time-1.yaml │ ├── spec-date-time-4.toml │ ├── spec-date-time-4.yaml │ ├── spec-float-10.toml │ ├── spec-float-10.yaml │ ├── spec-float-11.toml │ ├── spec-float-11.yaml │ ├── spec-float-12.toml │ ├── spec-float-12.yaml │ ├── spec-int-max.toml │ ├── spec-int-min.toml │ ├── spec-key-value-pair-9.yaml │ ├── spec-string-basic-tab.toml │ ├── spec-string-basic-tab.yaml │ ├── spec-string-literal-4.toml │ ├── spec-table-inline-2.toml │ ├── spec-table-inline-2.yaml │ ├── spec-array-2.toml │ ├── spec-array-2.yaml │ ├── spec-date-time-2.toml │ ├── spec-date-time-2.yaml │ ├── spec-date-time-5.toml │ ├── spec-date-time-5.yaml │ ├── spec-date-time-6.toml │ ├── spec-date-time-6.yaml │ ├── spec-date-time-local-1.toml │ ├── spec-newline-3.toml │ ├── spec-newline-3.yaml │ ├── spec-table-4.toml │ ├── spec-table-5.toml │ ├── spec-table-7.yaml │ ├── spec-table-inline-3.toml │ ├── spec-date-time-3.toml │ ├── spec-date-time-3.yaml │ ├── spec-date-time-local-2.toml │ ├── spec-int-7.toml │ ├── spec-int-7.yaml │ ├── spec-quoted-literal-keys-1.toml │ ├── spec-quoted-literal-keys-1.yaml │ ├── spec-string-basic-multiline-4.toml │ ├── spec-string-basic-tab-multiline.yaml │ ├── spec-table-2.toml │ ├── spec-table-6.toml │ ├── spec-table-inline-3.yaml │ ├── spec-array-3.toml │ ├── spec-array-3.yaml │ ├── spec-comment-mid-string.toml │ ├── spec-comment-mid-string.yaml │ ├── spec-int-oct2.toml │ ├── spec-string-basic-tab-multiline.toml │ ├── spec-string-literal-1.toml │ ├── spec-string-literal-1.yaml │ ├── spec-string-literal-2.toml │ ├── spec-string-literal-2.yaml │ ├── spec-string-literal-3.toml │ ├── spec-string-literal-3.yaml │ ├── spec-array-5.toml │ ├── spec-array-5.yaml │ ├── spec-array-8.toml │ ├── spec-array-8.yaml │ ├── spec-array-mixed-number-types.toml │ ├── spec-array-mixed-number-types.yaml │ ├── spec-empty-key-name-1.toml │ ├── spec-empty-key-name-2.toml │ ├── spec-table-inline-1.yaml │ ├── spec-array-4.yaml │ ├── spec-string-basic-multiline-1.yaml │ ├── spec-string-literal-multiline-1.yaml │ ├── spec-table-inline-1.toml │ ├── spec-case-sensitive.toml │ ├── spec-float-15.toml │ ├── spec-string-basic-multiline-5.yaml │ ├── spec-string-basic-multiline-7.yaml │ ├── spec-string-literal-multiline-1.toml │ ├── spec-table-2.yaml │ ├── spec-array-4.toml │ ├── spec-float-13.toml │ ├── spec-float-13.yaml │ ├── spec-string-basic-multiline-2.yaml │ ├── spec-string-basic-multiline-3.yaml │ ├── spec-string-basic-multiline-7.toml │ ├── spec-string-literal-multiline-4.yaml │ ├── spec-extend-dotted-object-1.yaml │ ├── spec-string-basic-multiline-1.toml │ ├── spec-string-basic-multiline-6.yaml │ ├── spec-string-literal-multiline-4.toml │ ├── spec-int-max.json │ ├── spec-int-min.json │ ├── spec-string-basic-multiline-6.toml │ ├── spec-string-basic-multiline-8.yaml │ ├── spec-string-basic-multiline-9.yaml │ ├── spec-string-basic.yaml │ ├── spec-string-literal-multiline-3.yaml │ ├── spec-string-basic-multiline-9.toml │ ├── spec-string-basic.toml │ ├── spec-string-literal-multiline-3.toml │ ├── spec-comment.toml │ ├── spec-comment.yaml │ ├── spec-string-basic-multiline-8.toml │ ├── spec-time-1.json │ ├── spec-time-2.json │ ├── spec-date-local-1.json │ ├── spec-string-basic-multiline-5.toml │ ├── spec-string-basic-multiline-2.toml │ ├── spec-table-1.yaml │ ├── spec-dotted-keys-1.toml │ ├── spec-dotted-keys-1.yaml │ ├── spec-table-1.toml │ ├── spec-array-of-tables-3.yaml │ ├── spec-date-time-local-1.json │ ├── spec-date-time-local-2.json │ ├── spec-string-literal-multiline-2.yaml │ ├── spec-table-8.yaml │ ├── spec-string-basic-multiline-3.toml │ ├── spec-array-of-tables-3.toml │ ├── spec-array-of-tables-1.yaml │ ├── spec-table-7.toml │ ├── spec-table-8.toml │ ├── spec-comment-tab.toml │ ├── spec-string-literal-multiline-2.toml │ ├── spec-comment-mid-array.yaml │ ├── spec-comment-mid-array.toml │ ├── spec-array-more-mixed-types.toml │ ├── spec-array-more-mixed-types.yaml │ ├── spec-extend-dotted-object-2.yaml │ ├── spec-extend-dotted-object-3.yaml │ ├── spec-extend-dotted-object-1.toml │ ├── spec-array-of-tables-1.toml │ ├── spec-extend-dotted-object-3.toml │ ├── spec-extend-dotted-object-2.toml │ ├── spec-array-of-tables-2.toml │ ├── spec-array-of-tables-2.yaml │ ├── spec-readme-example.yaml │ └── spec-readme-example.toml ├── go.mod ├── .github └── workflows │ └── go.yml ├── internal ├── stack.go ├── map_test.go ├── defs.go ├── convert_test.go ├── encoder_test.go └── convert.go ├── example_test.go ├── LICENSE ├── go.sum ├── README.md └── reader.go /spec-tests/tests/valid/empty-file.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec-tests/errors/bare-key-3.toml: -------------------------------------------------------------------------------- 1 | barekey = -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/empty.toml: -------------------------------------------------------------------------------- 1 | = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/empty.toml: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/noeol.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/empty-file.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/empty.toml: -------------------------------------------------------------------------------- 1 | [a] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-1.toml: -------------------------------------------------------------------------------- 1 | int1 = +99 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-1.yaml: -------------------------------------------------------------------------------- 1 | int1: 99 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-2.toml: -------------------------------------------------------------------------------- 1 | int2 = 42 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-2.yaml: -------------------------------------------------------------------------------- 1 | int2: 42 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-3.toml: -------------------------------------------------------------------------------- 1 | int3 = 0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-3.yaml: -------------------------------------------------------------------------------- 1 | int3: 0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-3a.toml: -------------------------------------------------------------------------------- 1 | int3 = +0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-3a.yaml: -------------------------------------------------------------------------------- 1 | int3: 0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-3b.toml: -------------------------------------------------------------------------------- 1 | int3 = -0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-3b.yaml: -------------------------------------------------------------------------------- 1 | int3: 0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-4.toml: -------------------------------------------------------------------------------- 1 | int4 = -17 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-4.yaml: -------------------------------------------------------------------------------- 1 | int4: -17 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-3.toml: -------------------------------------------------------------------------------- 1 | [a.b.c] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table.toml: -------------------------------------------------------------------------------- 1 | [table] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table.yaml: -------------------------------------------------------------------------------- 1 | table: {} 2 | -------------------------------------------------------------------------------- /spec-tests/errors/bare-key-1.toml: -------------------------------------------------------------------------------- 1 | bare!key = 123 2 | -------------------------------------------------------------------------------- /spec-tests/errors/int-0-padded.toml: -------------------------------------------------------------------------------- 1 | int = 0123 2 | -------------------------------------------------------------------------------- /spec-tests/errors/int-signed-bin.toml: -------------------------------------------------------------------------------- 1 | bin = +0b10 2 | -------------------------------------------------------------------------------- /spec-tests/errors/int-signed-hex.toml: -------------------------------------------------------------------------------- 1 | hex = +0xab 2 | -------------------------------------------------------------------------------- /spec-tests/errors/int-signed-oct.toml: -------------------------------------------------------------------------------- 1 | oct = +0o23 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/hash.toml: -------------------------------------------------------------------------------- 1 | a# = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/space.toml: -------------------------------------------------------------------------------- 1 | a b = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/numeric.toml: -------------------------------------------------------------------------------- 1 | 1 = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/space.toml: -------------------------------------------------------------------------------- 1 | "a b" = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/no-eol.toml: -------------------------------------------------------------------------------- 1 | [table] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-boolean-1.yaml: -------------------------------------------------------------------------------- 1 | bool1: true 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-1.toml: -------------------------------------------------------------------------------- 1 | flt1 = +1.0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-1.yaml: -------------------------------------------------------------------------------- 1 | flt1: 1.0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-14.yaml: -------------------------------------------------------------------------------- 1 | sf5: .nan 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-15.yaml: -------------------------------------------------------------------------------- 1 | sf6: .NAN 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-2.toml: -------------------------------------------------------------------------------- 1 | flt2 = 3.1415 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-2.yaml: -------------------------------------------------------------------------------- 1 | flt2: 3.1415 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-3.toml: -------------------------------------------------------------------------------- 1 | flt3 = -0.01 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-3.yaml: -------------------------------------------------------------------------------- 1 | flt3: -0.01 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-4.toml: -------------------------------------------------------------------------------- 1 | flt4 = 5e+22 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-4.yaml: -------------------------------------------------------------------------------- 1 | flt4: 5e+22 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-5.toml: -------------------------------------------------------------------------------- 1 | flt5 = 1e06 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-5.yaml: -------------------------------------------------------------------------------- 1 | flt5: 1e6 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-6.toml: -------------------------------------------------------------------------------- 1 | flt6 = -2E-2 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-6.yaml: -------------------------------------------------------------------------------- 1 | flt6: -2E-2 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-9.toml: -------------------------------------------------------------------------------- 1 | flt9 = -0e0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-9.yaml: -------------------------------------------------------------------------------- 1 | flt9: -0e0 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-5.toml: -------------------------------------------------------------------------------- 1 | int5 = 1_000 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-5.yaml: -------------------------------------------------------------------------------- 1 | int5: 1_000 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-6.yaml: -------------------------------------------------------------------------------- 1 | int6: 5_349_221 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-bin1.yaml: -------------------------------------------------------------------------------- 1 | bin1: 214 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-oct1.yaml: -------------------------------------------------------------------------------- 1 | oct1: 342391 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-oct2.yaml: -------------------------------------------------------------------------------- 1 | oct2: 493 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-6.toml: -------------------------------------------------------------------------------- 1 | -=1 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-6.yaml: -------------------------------------------------------------------------------- 1 | "-": 1 -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-7.toml: -------------------------------------------------------------------------------- 1 | _=1 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-7.yaml: -------------------------------------------------------------------------------- 1 | "_": 1 -------------------------------------------------------------------------------- /spec-tests/values/spec-time-1.toml: -------------------------------------------------------------------------------- 1 | lt1 = 07:32:00 2 | -------------------------------------------------------------------------------- /spec-tests/errors/bare-key-2.toml: -------------------------------------------------------------------------------- 1 | barekey 2 | = 123 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/no-eol.toml: -------------------------------------------------------------------------------- 1 | a = 1 b = 2 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/two-equals.toml: -------------------------------------------------------------------------------- 1 | key= = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/two-equals2.toml: -------------------------------------------------------------------------------- 1 | a==1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/two-equals3.toml: -------------------------------------------------------------------------------- 1 | a=b=1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/without-value-1.toml: -------------------------------------------------------------------------------- 1 | key 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/llbrace.toml: -------------------------------------------------------------------------------- 1 | [ [table]] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/rrbrace.toml: -------------------------------------------------------------------------------- 1 | [[table] ] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/empty.toml: -------------------------------------------------------------------------------- 1 | "" = "blank" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/numeric-dotted.toml: -------------------------------------------------------------------------------- 1 | 1.2 = 3 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/empty.toml: -------------------------------------------------------------------------------- 1 | answer = "" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-boolean-1.toml: -------------------------------------------------------------------------------- 1 | bool1 = true 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-boolean-2.toml: -------------------------------------------------------------------------------- 1 | bool1 = false 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-boolean-2.yaml: -------------------------------------------------------------------------------- 1 | bool1: false 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment-tab.yaml: -------------------------------------------------------------------------------- 1 | key: "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-dotted-keys-2.toml: -------------------------------------------------------------------------------- 1 | a . b = 23 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-7.toml: -------------------------------------------------------------------------------- 1 | flt7 = 6.626e-34 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-7.yaml: -------------------------------------------------------------------------------- 1 | flt7: 6.626e-34 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-6.toml: -------------------------------------------------------------------------------- 1 | int6 = 5_349_221 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-bin1.toml: -------------------------------------------------------------------------------- 1 | bin1 = 0b11010110 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-hex1.toml: -------------------------------------------------------------------------------- 1 | hex1 = 0xDEADBEEF 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-hex1.yaml: -------------------------------------------------------------------------------- 1 | hex1: 3735928559 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-hex2.toml: -------------------------------------------------------------------------------- 1 | hex2 = 0xdeadbeef 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-hex2.yaml: -------------------------------------------------------------------------------- 1 | hex2: 3735928559 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-hex3.yaml: -------------------------------------------------------------------------------- 1 | hex3: 3735928559 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-oct1.toml: -------------------------------------------------------------------------------- 1 | oct1 = 0o01234567 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-8.yaml: -------------------------------------------------------------------------------- 1 | "-_-_-_-_-": 1 -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-1.toml: -------------------------------------------------------------------------------- 1 | a = "\b" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-1.yaml: -------------------------------------------------------------------------------- 1 | a: "\b" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-2.toml: -------------------------------------------------------------------------------- 1 | a = "\t" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-2.yaml: -------------------------------------------------------------------------------- 1 | a: "\t" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-3.toml: -------------------------------------------------------------------------------- 1 | a = "\n" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-3.yaml: -------------------------------------------------------------------------------- 1 | a: "\n" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-4.toml: -------------------------------------------------------------------------------- 1 | a = "\f" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-4.yaml: -------------------------------------------------------------------------------- 1 | a: "\f" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-5.toml: -------------------------------------------------------------------------------- 1 | a = "\r" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-5.yaml: -------------------------------------------------------------------------------- 1 | a: "\r" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-6.toml: -------------------------------------------------------------------------------- 1 | a = "\"" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-6.yaml: -------------------------------------------------------------------------------- 1 | a: "\"" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-7.toml: -------------------------------------------------------------------------------- 1 | a = "\\" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-7.yaml: -------------------------------------------------------------------------------- 1 | a: "\\" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-8.yaml: -------------------------------------------------------------------------------- 1 | a: "\x00" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-9.yaml: -------------------------------------------------------------------------------- 1 | a: "\x00" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/comment-control-1.toml: -------------------------------------------------------------------------------- 1 | a = "null" # 2 | -------------------------------------------------------------------------------- /spec-tests/errors/comment-control-2.toml: -------------------------------------------------------------------------------- 1 | a = "ctrl-P" #  2 | -------------------------------------------------------------------------------- /spec-tests/errors/comment-control-3.toml: -------------------------------------------------------------------------------- 1 | a = "ctrl-_" #  2 | -------------------------------------------------------------------------------- /spec-tests/errors/comment-control-4.toml: -------------------------------------------------------------------------------- 1 | a = "0x7f" #  2 | -------------------------------------------------------------------------------- /spec-tests/errors/key-value-pair-1.toml: -------------------------------------------------------------------------------- 1 | key = # INVALID 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-control-1.toml: -------------------------------------------------------------------------------- 1 | a = "null" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-control-2.toml: -------------------------------------------------------------------------------- 1 | a = "ctrl-P" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-control-3.toml: -------------------------------------------------------------------------------- 1 | a = "ctrl-_" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-control-4.toml: -------------------------------------------------------------------------------- 1 | a = "0x7f" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-unknown-escape.toml: -------------------------------------------------------------------------------- 1 | a = "\@" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-control-1.toml: -------------------------------------------------------------------------------- 1 | a = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-control-2.toml: -------------------------------------------------------------------------------- 1 | a = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-control-3.toml: -------------------------------------------------------------------------------- 1 | a = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-control-4.toml: -------------------------------------------------------------------------------- 1 | a = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/no-close-2.toml: -------------------------------------------------------------------------------- 1 | x = [42 # 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/bool/mixed-case.toml: -------------------------------------------------------------------------------- 1 | valid = False 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/bool/wrong-case-true.toml: -------------------------------------------------------------------------------- 1 | a = TRUE 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/empty.toml: -------------------------------------------------------------------------------- 1 | t = {,} 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/open-bracket.toml: -------------------------------------------------------------------------------- 1 | [abc = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/single-open-bracket.toml: -------------------------------------------------------------------------------- 1 | [ 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/without-value-2.toml: -------------------------------------------------------------------------------- 1 | key = 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/equals-sign.toml: -------------------------------------------------------------------------------- 1 | [name=bad] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/bool.toml: -------------------------------------------------------------------------------- 1 | a = [true, false] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nospaces.toml: -------------------------------------------------------------------------------- 1 | ints = [1,2,3] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/equals-nospace.toml: -------------------------------------------------------------------------------- 1 | answer=42 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/sub-empty.toml: -------------------------------------------------------------------------------- 1 | [a] 2 | [a.b] 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/whitespace.toml: -------------------------------------------------------------------------------- 1 | ["valid key"] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-1.toml: -------------------------------------------------------------------------------- 1 | integers = [ 1, 2, 3 ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-1.yaml: -------------------------------------------------------------------------------- 1 | integers: [ 1, 2, 3 ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-local-1.toml: -------------------------------------------------------------------------------- 1 | ld1 = 1979-05-27 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-dotted-keys-2.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | b: 23 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-dotted-keys-3.toml: -------------------------------------------------------------------------------- 1 | a . b = 23 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-dotted-keys-3.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | b: 23 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-empty-key-name-1.yaml: -------------------------------------------------------------------------------- 1 | "": "blank" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-empty-key-name-2.yaml: -------------------------------------------------------------------------------- 1 | "": "blank" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-8.yaml: -------------------------------------------------------------------------------- 1 | flt8: 224_617.445_991_228 -------------------------------------------------------------------------------- /spec-tests/values/spec-int-hex3.toml: -------------------------------------------------------------------------------- 1 | hex3 = 0xdead_beef 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-1.toml: -------------------------------------------------------------------------------- 1 | key = "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-1.yaml: -------------------------------------------------------------------------------- 1 | key: "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-4.toml: -------------------------------------------------------------------------------- 1 | 1234 = "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-5.toml: -------------------------------------------------------------------------------- 1 | 1234="value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-8.toml: -------------------------------------------------------------------------------- 1 | -_-_-_-_-=1 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-9.toml: -------------------------------------------------------------------------------- 1 | 3.14159 = "pi" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-newline-1.yaml: -------------------------------------------------------------------------------- 1 | abc: 123 2 | def: 456 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-newline-2.yaml: -------------------------------------------------------------------------------- 1 | abc: 123 2 | def: 456 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-8.toml: -------------------------------------------------------------------------------- 1 | a = "\u0000" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-time-2.toml: -------------------------------------------------------------------------------- 1 | lt2 = 00:32:00.999999 2 | -------------------------------------------------------------------------------- /spec-tests/errors/no-key-name.toml: -------------------------------------------------------------------------------- 1 | = "no key name" # INVALID 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/bool/wrong-case-false.toml: -------------------------------------------------------------------------------- 1 | b = FALSE 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/leading-us.toml: -------------------------------------------------------------------------------- 1 | leading-us = _1.2 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/newline.toml: -------------------------------------------------------------------------------- 1 | barekey 2 | = 123 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-uni-esc.toml: -------------------------------------------------------------------------------- 1 | str = "val\ue" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/missing-quotes.toml: -------------------------------------------------------------------------------- 1 | name = value 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-no-close-2.toml: -------------------------------------------------------------------------------- 1 | x=""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/whitespace.toml: -------------------------------------------------------------------------------- 1 | [invalid key] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/empty.toml: -------------------------------------------------------------------------------- 1 | thevoid = [[[[[]]]]] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nested.toml: -------------------------------------------------------------------------------- 1 | nest = [["a"], ["b"]] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/bool/bool.toml: -------------------------------------------------------------------------------- 1 | t = true 2 | f = false 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/unicode-literal.toml: -------------------------------------------------------------------------------- 1 | answer = "δ" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": {} 3 | } 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-case-sensitive.yaml: -------------------------------------------------------------------------------- 1 | abc: 123 2 | ABC: 456 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-14.toml: -------------------------------------------------------------------------------- 1 | sf5 = +nan # same as `nan` 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-8.toml: -------------------------------------------------------------------------------- 1 | flt8 = 224_617.445_991_228 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-2.toml: -------------------------------------------------------------------------------- 1 | bare_key = "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-2.yaml: -------------------------------------------------------------------------------- 1 | bare_key: "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-3.toml: -------------------------------------------------------------------------------- 1 | bare-key = "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-3.yaml: -------------------------------------------------------------------------------- 1 | bare-key: "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-4.yaml: -------------------------------------------------------------------------------- 1 | "1234": "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-5.yaml: -------------------------------------------------------------------------------- 1 | "1234": "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-newline-1.toml: -------------------------------------------------------------------------------- 1 | abc = 123 2 | def = 456 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-newline-2.toml: -------------------------------------------------------------------------------- 1 | abc = 123 2 | def = 456 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-quoted-basic-keys-1.toml: -------------------------------------------------------------------------------- 1 | "ʎǝʞ" = "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-quoted-basic-keys-1.yaml: -------------------------------------------------------------------------------- 1 | "ʎǝʞ": "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-4.yaml: -------------------------------------------------------------------------------- 1 | a: "abcdef" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-escape-9.toml: -------------------------------------------------------------------------------- 1 | a = "\U00000000" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-4.yaml: -------------------------------------------------------------------------------- 1 | regex: '<\i\c*\s*>' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-3.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | b: 3 | c: {} 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-4.yaml: -------------------------------------------------------------------------------- 1 | d: 2 | e: 3 | f: {} 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-5.yaml: -------------------------------------------------------------------------------- 1 | g: 2 | h: 3 | i: {} 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-6.yaml: -------------------------------------------------------------------------------- 1 | j: 2 | "ʞ": 3 | l: {} 4 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/no-close-table.toml: -------------------------------------------------------------------------------- 1 | x = [{ key = 42 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/no-close.toml: -------------------------------------------------------------------------------- 1 | long_array = [ 1, 2, 3 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/multi-lf.toml: -------------------------------------------------------------------------------- 1 | multi-lf = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/multi-us.toml: -------------------------------------------------------------------------------- 1 | multi-us = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/string-del.toml: -------------------------------------------------------------------------------- 1 | string-del = "null" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/string-lf.toml: -------------------------------------------------------------------------------- 1 | string-lf = "null" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/string-us.toml: -------------------------------------------------------------------------------- 1 | string-us = "null" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/exp-point-1.toml: -------------------------------------------------------------------------------- 1 | exp-point-1 = 1e2.3 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/exp-point-2.toml: -------------------------------------------------------------------------------- 1 | exp-point-2 = 1.e2 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/leading-zero.toml: -------------------------------------------------------------------------------- 1 | leading-zero = 03.14 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/trailing-us.toml: -------------------------------------------------------------------------------- 1 | trailing-us = 1.2_ 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/no-comma.toml: -------------------------------------------------------------------------------- 1 | t = {x = 3 y = 4} 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/capital-bin.toml: -------------------------------------------------------------------------------- 1 | capital-bin = 0B0 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/capital-hex.toml: -------------------------------------------------------------------------------- 1 | capital-hex = 0X1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/capital-oct.toml: -------------------------------------------------------------------------------- 1 | capital-oct = 0O0 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/double-us.toml: -------------------------------------------------------------------------------- 1 | double-us = 1__23 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/invalid-oct.toml: -------------------------------------------------------------------------------- 1 | invalid-oct = 0o778 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-us.toml: -------------------------------------------------------------------------------- 1 | leading-us = _123 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/trailing-us.toml: -------------------------------------------------------------------------------- 1 | trailing-us = 123_ 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/multiline.toml: -------------------------------------------------------------------------------- 1 | """long 2 | key""" = 1 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/partial-quoted.toml: -------------------------------------------------------------------------------- 1 | partial"quoted" = 5 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-byte-escape.toml: -------------------------------------------------------------------------------- 1 | naughty = "\xAg" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-unknown-escape.toml: -------------------------------------------------------------------------------- 1 | a = "\@" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/implicit-groups.toml: -------------------------------------------------------------------------------- 1 | [a.b.c] 2 | answer = 42 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/newline-lf.toml: -------------------------------------------------------------------------------- 1 | os = "unix" 2 | newline = "lf" 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/escaped-escape.toml: -------------------------------------------------------------------------------- 1 | answer = "\\x64" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/no-eol.json: -------------------------------------------------------------------------------- 1 | { 2 | "table": {} 3 | } 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-7.toml: -------------------------------------------------------------------------------- 1 | integers2 = [ 2 | 1, 2, 3 3 | ] 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-7.yaml: -------------------------------------------------------------------------------- 1 | integers2: [ 2 | 1, 2, 3 3 | ] 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-1.toml: -------------------------------------------------------------------------------- 1 | odt1 = 1979-05-27T07:32:00Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-1.yaml: -------------------------------------------------------------------------------- 1 | odt1: 1979-05-27T07:32:00Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-4.toml: -------------------------------------------------------------------------------- 1 | odt4 = 1979-05-27 07:32:00Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-4.yaml: -------------------------------------------------------------------------------- 1 | odt4: 1979-05-27 07:32:00Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-10.toml: -------------------------------------------------------------------------------- 1 | sf1 = inf # positive infinity 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-10.yaml: -------------------------------------------------------------------------------- 1 | sf1: .inf # positive infinity 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-11.toml: -------------------------------------------------------------------------------- 1 | sf2 = +inf # positive infinity 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-11.yaml: -------------------------------------------------------------------------------- 1 | sf2: .inf # positive infinity 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-12.toml: -------------------------------------------------------------------------------- 1 | sf2 = -inf # negative infinity 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-12.yaml: -------------------------------------------------------------------------------- 1 | sf2: -.inf # negative infinity 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-max.toml: -------------------------------------------------------------------------------- 1 | max=9_223_372_036_854_775_807 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-min.toml: -------------------------------------------------------------------------------- 1 | min=-9_223_372_036_854_775_808 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-key-value-pair-9.yaml: -------------------------------------------------------------------------------- 1 | 3: 2 | 14159: "pi" 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-tab.toml: -------------------------------------------------------------------------------- 1 | str = "This is a tab" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-tab.yaml: -------------------------------------------------------------------------------- 1 | str: "This is a\ttab" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-4.toml: -------------------------------------------------------------------------------- 1 | regex = '<\i\c*\s*>' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-inline-2.toml: -------------------------------------------------------------------------------- 1 | point = { x = 1, y = 2 } 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-inline-2.yaml: -------------------------------------------------------------------------------- 1 | point: { x: 1, y: 2 } 2 | -------------------------------------------------------------------------------- /spec-tests/errors/inline-table-trailing-comma.toml: -------------------------------------------------------------------------------- 1 | abc = { abc = 123, } 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-control-1.toml: -------------------------------------------------------------------------------- 1 | a = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-control-2.toml: -------------------------------------------------------------------------------- 1 | a = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-control-3.toml: -------------------------------------------------------------------------------- 1 | a = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-control-4.toml: -------------------------------------------------------------------------------- 1 | a = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-unknown-escape.toml: -------------------------------------------------------------------------------- 1 | a = """\@""" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-multiline-control-1.toml: -------------------------------------------------------------------------------- 1 | a = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-multiline-control-2.toml: -------------------------------------------------------------------------------- 1 | a = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-multiline-control-3.toml: -------------------------------------------------------------------------------- 1 | a = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-multiline-control-4.toml: -------------------------------------------------------------------------------- 1 | a = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/missing-separator.toml: -------------------------------------------------------------------------------- 1 | wrong = [ 1 2 3 ] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/no-close-table-2.toml: -------------------------------------------------------------------------------- 1 | x = [{ key = 42 # 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/bare-null.toml: -------------------------------------------------------------------------------- 1 | bare-null = "some value" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/comment-del.toml: -------------------------------------------------------------------------------- 1 | comment-del = "0x7f" #  2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/comment-lf.toml: -------------------------------------------------------------------------------- 1 | comment-lf = "ctrl-P" #  2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/comment-us.toml: -------------------------------------------------------------------------------- 1 | comment-us = "ctrl-_" #  2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/multi-del.toml: -------------------------------------------------------------------------------- 1 | multi-del = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/multi-null.toml: -------------------------------------------------------------------------------- 1 | multi-null = """null""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawstring-lf.toml: -------------------------------------------------------------------------------- 1 | rawstring-lf = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawstring-us.toml: -------------------------------------------------------------------------------- 1 | rawstring-us = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/string-bs.toml: -------------------------------------------------------------------------------- 1 | string-bs = "backspace" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/string-null.toml: -------------------------------------------------------------------------------- 1 | string-null = "null" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/double-point-1.toml: -------------------------------------------------------------------------------- 1 | double-point-1 = 0..1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/double-point-2.toml: -------------------------------------------------------------------------------- 1 | double-point-2 = 0.1.2 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/exp-double-e-1.toml: -------------------------------------------------------------------------------- 1 | exp-double-e-1 = 1ee2 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/exp-double-e-2.toml: -------------------------------------------------------------------------------- 1 | exp-double-e-2 = 1e2e3 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/exp-double-us.toml: -------------------------------------------------------------------------------- 1 | exp-double-us = 1e__23 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/exp-leading-us.toml: -------------------------------------------------------------------------------- 1 | exp-leading-us = 1e_23 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/inf-incomplete-1.toml: -------------------------------------------------------------------------------- 1 | inf-incomplete-1 = in 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/inf_underscore.toml: -------------------------------------------------------------------------------- 1 | inf_underscore = in_f 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/leading-point.toml: -------------------------------------------------------------------------------- 1 | leading-point = .12345 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/nan-incomplete-1.toml: -------------------------------------------------------------------------------- 1 | nan-incomplete-1 = na 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/nan_underscore.toml: -------------------------------------------------------------------------------- 1 | nan_underscore = na_n 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/trailing-point.toml: -------------------------------------------------------------------------------- 1 | trailing-point = 1. 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/us-after-point.toml: -------------------------------------------------------------------------------- 1 | us-after-point = 1._2 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/us-before-point.toml: -------------------------------------------------------------------------------- 1 | us-before-point = 1_.2 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/double-comma.toml: -------------------------------------------------------------------------------- 1 | t = {x=3,,y=4} 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/linebreak-2.toml: -------------------------------------------------------------------------------- 1 | t = {a=1, 2 | b=2} 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/linebreak-3.toml: -------------------------------------------------------------------------------- 1 | t = {a=1 2 | ,b=2} 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/invalid-bin.toml: -------------------------------------------------------------------------------- 1 | invalid-bin = 0b0012 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/invalid-hex.toml: -------------------------------------------------------------------------------- 1 | invalid-hex = 0xaafz 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-us-bin.toml: -------------------------------------------------------------------------------- 1 | leading-us-bin = _0o1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-us-hex.toml: -------------------------------------------------------------------------------- 1 | leading-us-hex = _0o1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-us-oct.toml: -------------------------------------------------------------------------------- 1 | leading-us-oct = _0o1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-zero-1.toml: -------------------------------------------------------------------------------- 1 | leading-zero-1 = 01 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-zero-2.toml: -------------------------------------------------------------------------------- 1 | leading-zero-2 = 00 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-zero-3.toml: -------------------------------------------------------------------------------- 1 | leading-zero-3 = 0_0 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/negative-hex.toml: -------------------------------------------------------------------------------- 1 | negative-hex = -0xff 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/negative-oct.toml: -------------------------------------------------------------------------------- 1 | negative-oct = -0o99 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/positive-hex.toml: -------------------------------------------------------------------------------- 1 | positive-hex = +0xff 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/positive-oct.toml: -------------------------------------------------------------------------------- 1 | positive-oct = +0o99 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/us-after-bin.toml: -------------------------------------------------------------------------------- 1 | us-after-bin = 0b_1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/us-after-hex.toml: -------------------------------------------------------------------------------- 1 | us-after-hex = 0x_1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/us-after-oct.toml: -------------------------------------------------------------------------------- 1 | us-after-oct = 0o_1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/bare-invalid-character.toml: -------------------------------------------------------------------------------- 1 | bare!key = 123 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/start-bracket.toml: -------------------------------------------------------------------------------- 1 | [a] 2 | [xyz = 5 3 | [b] 4 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-byte-escapes.toml: -------------------------------------------------------------------------------- 1 | answer = "\x33" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/with-pound.toml: -------------------------------------------------------------------------------- 1 | [key#group] 2 | answer = 42 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nested-inline-table.toml: -------------------------------------------------------------------------------- 1 | a = [ { b = {} } ] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/string-quote-comma-2.toml: -------------------------------------------------------------------------------- 1 | title = [ " \", ",] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/local-date.toml: -------------------------------------------------------------------------------- 1 | bestdayever = 1987-07-05 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/bool.toml: -------------------------------------------------------------------------------- 1 | a = {a = true, b = false} 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/newline-crlf.toml: -------------------------------------------------------------------------------- 1 | os = "DOS" 2 | newline = "crlf" 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/double-quote-escape.toml: -------------------------------------------------------------------------------- 1 | test = "\"one\"" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/whitespace.json: -------------------------------------------------------------------------------- 1 | { 2 | "valid key": {} 3 | } 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/with-pound.toml: -------------------------------------------------------------------------------- 1 | ["key#group"] 2 | answer = 42 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-2.toml: -------------------------------------------------------------------------------- 1 | colors = [ "red", "yellow", "green" ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-2.yaml: -------------------------------------------------------------------------------- 1 | colors: [ "red", "yellow", "green" ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-2.toml: -------------------------------------------------------------------------------- 1 | odt2 = 1979-05-27T00:32:00-07:00 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-2.yaml: -------------------------------------------------------------------------------- 1 | odt2: 1979-05-27T00:32:00-07:00 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-5.toml: -------------------------------------------------------------------------------- 1 | odt5 = 1979-05-27T07:32:00.123Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-5.yaml: -------------------------------------------------------------------------------- 1 | odt5: 1979-05-27T07:32:00.123Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-6.toml: -------------------------------------------------------------------------------- 1 | odt6 = 1979-05-27T07:32:00.1239Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-6.yaml: -------------------------------------------------------------------------------- 1 | odt6: 1979-05-27T07:32:00.123Z 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-local-1.toml: -------------------------------------------------------------------------------- 1 | ldt1 = 1979-05-27T07:32:00 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-newline-3.toml: -------------------------------------------------------------------------------- 1 | abc = 123 2 | def = 456 3 | ghi = 789 -------------------------------------------------------------------------------- /spec-tests/values/spec-newline-3.yaml: -------------------------------------------------------------------------------- 1 | abc: 123 2 | def: 456 3 | ghi: 789 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-4.toml: -------------------------------------------------------------------------------- 1 | [ d.e.f ] # same as [d.e.f] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-5.toml: -------------------------------------------------------------------------------- 1 | [ g . h . i ] # same as [g.h.i] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-7.yaml: -------------------------------------------------------------------------------- 1 | x: 2 | y: 3 | z: 4 | w: {} 5 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-inline-3.toml: -------------------------------------------------------------------------------- 1 | animal = { type.name = "pug" } 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/comment-null.toml: -------------------------------------------------------------------------------- 1 | comment-null = "null" # 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawmulti-del.toml: -------------------------------------------------------------------------------- 1 | rawmulti-del = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawmulti-lf.toml: -------------------------------------------------------------------------------- 1 | rawmulti-lf = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawmulti-null.toml: -------------------------------------------------------------------------------- 1 | rawmulti-null = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawmulti-us.toml: -------------------------------------------------------------------------------- 1 | rawmulti-us = '''null''' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawstring-del.toml: -------------------------------------------------------------------------------- 1 | rawstring-del = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/rawstring-null.toml: -------------------------------------------------------------------------------- 1 | rawstring-null = 'null' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/exp-trailing-us.toml: -------------------------------------------------------------------------------- 1 | exp-trailing-us = 1e_23_ 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/inf-incomplete-2.toml: -------------------------------------------------------------------------------- 1 | inf-incomplete-2 = +in 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/inf-incomplete-3.toml: -------------------------------------------------------------------------------- 1 | inf-incomplete-3 = -in 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/leading-zero-neg.toml: -------------------------------------------------------------------------------- 1 | leading-zero-neg = -03.14 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/nan-incomplete-2.toml: -------------------------------------------------------------------------------- 1 | nan-incomplete-2 = +na 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/nan-incomplete-3.toml: -------------------------------------------------------------------------------- 1 | nan-incomplete-3 = -na 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/trailing-point-min.toml: -------------------------------------------------------------------------------- 1 | trailing-point-min = -1. 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/double-sign-nex.toml: -------------------------------------------------------------------------------- 1 | double-sign-nex = --99 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/double-sign-plus.toml: -------------------------------------------------------------------------------- 1 | double-sign-plus = ++99 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/negative-bin.toml: -------------------------------------------------------------------------------- 1 | negative-bin = -0b11010110 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/positive-bin.toml: -------------------------------------------------------------------------------- 1 | positive-bin = +0b11010110 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/trailing-us-bin.toml: -------------------------------------------------------------------------------- 1 | trailing-us-bin = 0b1_ 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/trailing-us-hex.toml: -------------------------------------------------------------------------------- 1 | trailing-us-hex = 0x1_ 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/trailing-us-oct.toml: -------------------------------------------------------------------------------- 1 | trailing-us-oct = 0o1_ 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/after-array.toml: -------------------------------------------------------------------------------- 1 | [[agencies]] owner = "S Cjelli" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/duplicate-keys.toml: -------------------------------------------------------------------------------- 1 | dupe = false 2 | dupe = true 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/special-character.toml: -------------------------------------------------------------------------------- 1 | μ = "greek small letter mu" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-concat.toml: -------------------------------------------------------------------------------- 1 | no_concat = "first" "second" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-bad-escape-1.toml: -------------------------------------------------------------------------------- 1 | k = """t\a""" 2 | 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-quotes-1.toml: -------------------------------------------------------------------------------- 1 | a = """6 quotes: """""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-quotes-2.toml: -------------------------------------------------------------------------------- 1 | a = """6 quotes: """""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/array-empty.toml: -------------------------------------------------------------------------------- 1 | [[]] 2 | name = "Born to Run" 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/duplicate-table-array.toml: -------------------------------------------------------------------------------- 1 | [tbl] 2 | [[tbl]] 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/duplicate-table-array2.toml: -------------------------------------------------------------------------------- 1 | [[tbl]] 2 | [tbl] 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/empty-implicit-table.toml: -------------------------------------------------------------------------------- 1 | [naughty..naughty] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/nested-brackets-close.toml: -------------------------------------------------------------------------------- 1 | [a]b] 2 | zyx = 42 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/nested-brackets-open.toml: -------------------------------------------------------------------------------- 1 | [a[b] 2 | zyx = 42 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-int-float.toml: -------------------------------------------------------------------------------- 1 | ints-and-floats = [1, 1.1] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/underscore.toml: -------------------------------------------------------------------------------- 1 | kilo = 1_000 2 | x = 1_1_1_1 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-3.toml: -------------------------------------------------------------------------------- 1 | odt3 = 1979-05-27T00:32:00.999999-07:00 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-3.yaml: -------------------------------------------------------------------------------- 1 | odt3: 1979-05-27T00:32:00.999999-07:00 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-local-2.toml: -------------------------------------------------------------------------------- 1 | ldt2 = 1979-05-27T00:32:00.999999 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-7.toml: -------------------------------------------------------------------------------- 1 | int7 = 1_2_3_4_5 # VALID but discouraged 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-7.yaml: -------------------------------------------------------------------------------- 1 | int7: 1_2_3_4_5 # VALID but discouraged 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-quoted-literal-keys-1.toml: -------------------------------------------------------------------------------- 1 | 'quoted "value"' = "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-quoted-literal-keys-1.yaml: -------------------------------------------------------------------------------- 1 | 'quoted "value"': "value" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-4.toml: -------------------------------------------------------------------------------- 1 | a = """abc\ 2 | def""" 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-tab-multiline.yaml: -------------------------------------------------------------------------------- 1 | str: "This is a\ttab" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-2.toml: -------------------------------------------------------------------------------- 1 | [dog."tater.man"] 2 | type.name = "pug" 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-6.toml: -------------------------------------------------------------------------------- 1 | [ j . "ʞ" . 'l' ] # same as [j."ʞ".'l'] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-inline-3.yaml: -------------------------------------------------------------------------------- 1 | animal: { type: { name: "pug" } } 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-out-of-range-unicode-escape-1.toml: -------------------------------------------------------------------------------- 1 | a = "\UFFFFFFFF" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-out-of-range-unicode-escape-2.toml: -------------------------------------------------------------------------------- 1 | a = "\U00D80000" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/leading-point-neg.toml: -------------------------------------------------------------------------------- 1 | leading-point-neg = -.12345 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/leading-point-plus.toml: -------------------------------------------------------------------------------- 1 | leading-point-plus = +.12345 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/leading-zero-plus.toml: -------------------------------------------------------------------------------- 1 | leading-zero-plus = +03.14 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/trailing-point-plus.toml: -------------------------------------------------------------------------------- 1 | trailing-point-plus = +1. 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-zero-sign-1.toml: -------------------------------------------------------------------------------- 1 | leading-zero-sign-1 = -01 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-zero-sign-2.toml: -------------------------------------------------------------------------------- 1 | leading-zero-sign-2 = +01 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/leading-zero-sign-3.toml: -------------------------------------------------------------------------------- 1 | leading-zero-sign-3 = +0_1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/after-table.toml: -------------------------------------------------------------------------------- 1 | [error] this = "should not be here" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-multiline-unknown-escape.toml: -------------------------------------------------------------------------------- 1 | a = """\@""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/duplicate.toml: -------------------------------------------------------------------------------- 1 | [a] 2 | b = 1 3 | 4 | [a] 5 | c = 2 6 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/text-after-table.toml: -------------------------------------------------------------------------------- 1 | [error] this shouldn't be here 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-int-string.toml: -------------------------------------------------------------------------------- 1 | strings-and-ints = ["hi", 42] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/noeol.toml: -------------------------------------------------------------------------------- 1 | # single comment without any eol characters -------------------------------------------------------------------------------- /spec-tests/values/spec-array-3.toml: -------------------------------------------------------------------------------- 1 | nested_array_of_int = [ [ 1, 2 ], [3, 4, 5] ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-3.yaml: -------------------------------------------------------------------------------- 1 | nested_array_of_int: [ [ 1, 2 ], [3, 4, 5] ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment-mid-string.toml: -------------------------------------------------------------------------------- 1 | another = "# This is not a comment" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment-mid-string.yaml: -------------------------------------------------------------------------------- 1 | another: "# This is not a comment" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-oct2.toml: -------------------------------------------------------------------------------- 1 | oct2 = 0o755 # useful for Unix file permissions 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-tab-multiline.toml: -------------------------------------------------------------------------------- 1 | str = """This is a tab""" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-1.toml: -------------------------------------------------------------------------------- 1 | winpath = 'C:\Users\nodejs\templates' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-1.yaml: -------------------------------------------------------------------------------- 1 | winpath: 'C:\Users\nodejs\templates' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-2.toml: -------------------------------------------------------------------------------- 1 | winpath2 = '\\ServerX\admin$\system32\' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-2.yaml: -------------------------------------------------------------------------------- 1 | winpath2: '\\ServerX\admin$\system32\' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-3.toml: -------------------------------------------------------------------------------- 1 | quoted = 'Tom "Dubs" Preston-Werner' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-3.yaml: -------------------------------------------------------------------------------- 1 | quoted: 'Tom "Dubs" Preston-Werner' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/key-value-pair-2.toml: -------------------------------------------------------------------------------- 1 | first = "Tom" last = "Preston-Werner" # INVALID 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/encoding/utf16.toml: -------------------------------------------------------------------------------- 1 | # UTF-16 without BOM 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/text-after-integer.toml: -------------------------------------------------------------------------------- 1 | answer = 42 the ultimate answer? 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/escape.toml: -------------------------------------------------------------------------------- 1 | \u00c0 = "latin capital letter A with grave" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-multiline.toml: -------------------------------------------------------------------------------- 1 | multi = "first line 2 | second line" 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-out-of-range-unicode-escape-1.toml: -------------------------------------------------------------------------------- 1 | a = "\UFFFFFFFF" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-out-of-range-unicode-escape-2.toml: -------------------------------------------------------------------------------- 1 | a = "\U00D80000" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/no-close.toml: -------------------------------------------------------------------------------- 1 | no-ending-quote = "One time, at band camp 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/wrong-close.toml: -------------------------------------------------------------------------------- 1 | bad-ending-quote = "double and single' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/quoted-no-close.toml: -------------------------------------------------------------------------------- 1 | ["where will it end] 2 | name = value 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/hetergeneous.toml: -------------------------------------------------------------------------------- 1 | mixed = [[1, 2], ["a", "b"], [1.1, 2.1]] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/special-chars.toml: -------------------------------------------------------------------------------- 1 | "~!@$^&*()_+-`1234567890[]|/?><.,;:'" = 1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/simple.toml: -------------------------------------------------------------------------------- 1 | answer = "You are not drinking enough whisky." 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-implicit.toml: -------------------------------------------------------------------------------- 1 | [[albums.songs]] 2 | name = "Glory Days" 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/sub-empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "b": {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-5.toml: -------------------------------------------------------------------------------- 1 | nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-5.yaml: -------------------------------------------------------------------------------- 1 | nested_mixed_array: [ [ 1, 2 ], ["a", "b", "c"] ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-8.toml: -------------------------------------------------------------------------------- 1 | integers3 = [ 2 | 1, 3 | 2, # this is ok 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-8.yaml: -------------------------------------------------------------------------------- 1 | integers3: [ 2 | 1, 3 | 2, # this is ok 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-mixed-number-types.toml: -------------------------------------------------------------------------------- 1 | numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-mixed-number-types.yaml: -------------------------------------------------------------------------------- 1 | numbers: [ 0.1, 0.2, 0.5, 1, 2, 5 ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-empty-key-name-1.toml: -------------------------------------------------------------------------------- 1 | "" = "blank" # VALID but discouraged 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-empty-key-name-2.toml: -------------------------------------------------------------------------------- 1 | '' = "blank" # VALID but discouraged 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-inline-1.yaml: -------------------------------------------------------------------------------- 1 | name: { first: "Tom", last: "Preston-Werner" } 2 | -------------------------------------------------------------------------------- /spec-tests/errors/multiple-key.toml: -------------------------------------------------------------------------------- 1 | # DO NOT DO THIS 2 | name = "Tom" 3 | name = "Pradyun" 4 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/after-value.toml: -------------------------------------------------------------------------------- 1 | first = "Tom" last = "Preston-Werner" # INVALID 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-no-close.toml: -------------------------------------------------------------------------------- 1 | invalid = """ 2 | this will fail 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/array-missing-bracket.toml: -------------------------------------------------------------------------------- 1 | [[albums] 2 | name = "Born to Run" 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/table-array-string-backslash.toml: -------------------------------------------------------------------------------- 1 | foo = [ { bar="\"{{baz}}\""} ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-4.yaml: -------------------------------------------------------------------------------- 1 | string_array: [ "all", "strings", "are the same", "type" ] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-1.yaml: -------------------------------------------------------------------------------- 1 | str1: "Roses are red\nViolets are blue" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-1.yaml: -------------------------------------------------------------------------------- 1 | regex2: "I [dw]on't need \\d{2} apples" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-inline-1.toml: -------------------------------------------------------------------------------- 1 | name = { first = "Tom", last = "Preston-Werner" } 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-invalid-backslash.toml: -------------------------------------------------------------------------------- 1 | a = """ 2 | foo \ \n 3 | bar""" 4 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-out-of-range-unicode-escape-1.toml: -------------------------------------------------------------------------------- 1 | a = """\UFFFFFFFF""" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-out-of-range-unicode-escape-2.toml: -------------------------------------------------------------------------------- 1 | a = """\U00D80000""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/comment-cr.toml: -------------------------------------------------------------------------------- 1 | comment-cr = "Carriage return in comment" # a=1 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/duplicate.toml: -------------------------------------------------------------------------------- 1 | # DO NOT DO THIS 2 | name = "Tom" 3 | name = "Pradyun" 4 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/literal-multiline-quotes-1.toml: -------------------------------------------------------------------------------- 1 | a = '''6 apostrophes: '''''' 2 | 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-escape-space.toml: -------------------------------------------------------------------------------- 1 | a = """ 2 | foo \ \n 3 | bar""" 4 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/text-after-string.toml: -------------------------------------------------------------------------------- 1 | string = "Is there life after strings?" No. 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/unicode-escape.toml: -------------------------------------------------------------------------------- 1 | answer4 = "\u03B4" 2 | answer8 = "\U000003B4" 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-case-sensitive.toml: -------------------------------------------------------------------------------- 1 | # TOML is case sensitive. 2 | abc = 123 3 | ABC = 456 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-15.toml: -------------------------------------------------------------------------------- 1 | sf6 = -nan # valid, actual encoding is implementation specific 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-5.yaml: -------------------------------------------------------------------------------- 1 | ml-escaped-nl: " foo bar \\\n baz \\quux" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-7.yaml: -------------------------------------------------------------------------------- 1 | str5: 'Here are three quotation marks: """.' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-1.toml: -------------------------------------------------------------------------------- 1 | regex2 = '''I [dw]on't need \d{2} apples''' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-2.yaml: -------------------------------------------------------------------------------- 1 | dog: 2 | "tater.man": 3 | type: 4 | name: "pug" 5 | -------------------------------------------------------------------------------- /spec-tests/errors/string-basic-multiline-quotes.toml: -------------------------------------------------------------------------------- 1 | str5 = """Here are three quotation marks: """.""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/no-secs.toml: -------------------------------------------------------------------------------- 1 | # No seconds in time. 2 | no-secs = 1987-07-05T17:45Z 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/time-no-leads-2.toml: -------------------------------------------------------------------------------- 1 | # Leading 0 is always required. 2 | d = 01:32:0 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/time-no-leads.toml: -------------------------------------------------------------------------------- 1 | # Leading 0 is always required. 2 | d = 1:32:00 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/trailing-t.toml: -------------------------------------------------------------------------------- 1 | # Date cannot end with trailing T 2 | d = 2006-01-30T 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-1.toml: -------------------------------------------------------------------------------- 1 | a = """\UFFFFFFFF""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-2.toml: -------------------------------------------------------------------------------- 1 | a = """\U00D80000""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-int-array.toml: -------------------------------------------------------------------------------- 1 | arrays-and-ints = [1, ["Arrays are not integers."]] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/local-time.toml: -------------------------------------------------------------------------------- 1 | besttimeever = 17:45:00 2 | milliseconds = 10:32:00.555 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/long.toml: -------------------------------------------------------------------------------- 1 | longpi = 3.141592653589793 2 | neglongpi = -3.141592653589793 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/with-single-quotes.toml: -------------------------------------------------------------------------------- 1 | ['a'] 2 | [a.'b'] 3 | [a.'b'.c] 4 | answer = 42 5 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-4.toml: -------------------------------------------------------------------------------- 1 | string_array = [ "all", 'strings', """are the same""", '''type'''] 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-13.toml: -------------------------------------------------------------------------------- 1 | sf4 = nan # actual sNaN/qNaN encoding is implementation specific 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-float-13.yaml: -------------------------------------------------------------------------------- 1 | sf4: .NAN # actual sNaN/qNaN encoding is implementation specific 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-2.yaml: -------------------------------------------------------------------------------- 1 | str: "The quick brown fox jumps over the lazy dog." 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-3.yaml: -------------------------------------------------------------------------------- 1 | str: "The quick brown fox jumps over the lazy dog." 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-7.toml: -------------------------------------------------------------------------------- 1 | str5 = """Here are three quotation marks: ""\".""" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-4.yaml: -------------------------------------------------------------------------------- 1 | str: "'That,' she said, 'is still pointless.'" 2 | -------------------------------------------------------------------------------- /spec-tests/errors/array-of-tables-1.toml: -------------------------------------------------------------------------------- 1 | # INVALID TOML DOC 2 | fruit = [] 3 | 4 | [[fruit]] # Not allowed 5 | -------------------------------------------------------------------------------- /spec-tests/errors/table-invalid-2.toml: -------------------------------------------------------------------------------- 1 | # INVALID TOML DOC 2 | fruit = [] 3 | 4 | [[fruit]] # Not allowed 5 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/basic-multiline-quotes.toml: -------------------------------------------------------------------------------- 1 | str5 = """Here are three quotation marks: """.""" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/literal-multiline-quotes-2.toml: -------------------------------------------------------------------------------- 1 | a = '''15 apostrophes: '''''''''''''''''' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nested-double.toml: -------------------------------------------------------------------------------- 1 | nest = [ 2 | [ 3 | ["a"], 4 | [1, 2, [3]] 5 | ] 6 | ] 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/strings.toml: -------------------------------------------------------------------------------- 1 | string_array = [ "all", 'strings', """are the same""", '''type'''] 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/datetime.toml: -------------------------------------------------------------------------------- 1 | space = 1987-07-05 17:45:00Z 2 | lower = 1987-07-05t17:45:00z 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/underscore.toml: -------------------------------------------------------------------------------- 1 | before = 3_141.5927 2 | after = 3141.592_7 3 | exponent = 3e1_4 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/implicit-and-explicit-after.toml: -------------------------------------------------------------------------------- 1 | [a.b.c] 2 | answer = 42 3 | 4 | [a] 5 | better = 43 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/implicit-and-explicit-before.toml: -------------------------------------------------------------------------------- 1 | [a] 2 | better = 43 3 | 4 | [a.b.c] 5 | answer = 42 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/integer.toml: -------------------------------------------------------------------------------- 1 | answer = 42 2 | posanswer = +42 3 | neganswer = -42 4 | zero = 0 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-one.toml: -------------------------------------------------------------------------------- 1 | [[people]] 2 | first_name = "Bruce" 3 | last_name = "Springsteen" 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/with-literal-string.toml: -------------------------------------------------------------------------------- 1 | ['a'] 2 | [a.'"b"'] 3 | [a.'"b"'.c] 4 | answer = 42 5 | -------------------------------------------------------------------------------- /spec-tests/values/spec-extend-dotted-object-1.yaml: -------------------------------------------------------------------------------- 1 | fruit: 2 | apple: 3 | smooth: true 4 | orange: 2 5 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-1.toml: -------------------------------------------------------------------------------- 1 | str1 = """ 2 | Roses are red 3 | Violets are blue""" 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-6.yaml: -------------------------------------------------------------------------------- 1 | str4: 'Here are two quotation marks: "". Simple enough.' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-4.toml: -------------------------------------------------------------------------------- 1 | str = ''''That,' she said, 'is still pointless.'''' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/tables-1.toml: -------------------------------------------------------------------------------- 1 | # INVALID TOML DOC 2 | fruit = [] 3 | 4 | [[fruit]] # Not allowed 5 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-escape-1.toml: -------------------------------------------------------------------------------- 1 | invalid-escape = "This string has a bad \a escape character." 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-bad-escape-2.toml: -------------------------------------------------------------------------------- 1 | # \ is not a valid escape. 2 | k = """t\ t""" 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/float.toml: -------------------------------------------------------------------------------- 1 | pi = 3.14 2 | pospi = +3.14 3 | negpi = -3.14 4 | zero-intpart = 0.123 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/long.toml: -------------------------------------------------------------------------------- 1 | int64-max = 9223372036854775807 2 | int64-max-neg = -9223372036854775808 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-max.json: -------------------------------------------------------------------------------- 1 | { 2 | "max": {"type": "integer", "value": "9223372036854775807"} 3 | } 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-int-min.json: -------------------------------------------------------------------------------- 1 | { 2 | "min": {"type": "integer", "value": "-9223372036854775808"} 3 | } 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-6.toml: -------------------------------------------------------------------------------- 1 | str4 = """Here are two quotation marks: "". Simple enough.""" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-8.yaml: -------------------------------------------------------------------------------- 1 | str6: 'Here are fifteen quotation marks: """"""""""""""".' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-9.yaml: -------------------------------------------------------------------------------- 1 | str7: '"This," she said, "is just a pointless statement."' 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic.yaml: -------------------------------------------------------------------------------- 1 | str: "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-3.yaml: -------------------------------------------------------------------------------- 1 | quot15: 'Here are fifteen quotation marks: """""""""""""""' 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/hour-over.toml: -------------------------------------------------------------------------------- 1 | # time-hour = 2DIGIT ; 00-23 2 | d = 2006-01-01T24:00:00-00:00 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/month-over.toml: -------------------------------------------------------------------------------- 1 | # date-month = 2DIGIT ; 01-12 2 | d = 2006-13-01T00:00:00-00:00 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/no-t.toml: -------------------------------------------------------------------------------- 1 | # No "t" or "T" between the date and time. 2 | no-t = 1987-07-0517:45:00Z 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-escape-2.toml: -------------------------------------------------------------------------------- 1 | invalid-escape = "This string has a bad \ escape character." 2 | 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-slash-escape.toml: -------------------------------------------------------------------------------- 1 | invalid-escape = "This string has a bad \/ escape character." 2 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/multiline-bad-escape-3.toml: -------------------------------------------------------------------------------- 1 | # \ is not a valid escape. 2 | k = """t\ """ 3 | 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/string-with-comma.toml: -------------------------------------------------------------------------------- 1 | title = [ 2 | "Client: XXXX, Job: XXXX", 3 | "Code: XXXX" 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "": { 3 | "type": "string", 4 | "value": "blank" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/numeric.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "type": "integer", 4 | "value": "1" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/space.json: -------------------------------------------------------------------------------- 1 | { 2 | "a b": { 3 | "type": "integer", 4 | "value": "1" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/keyword.json: -------------------------------------------------------------------------------- 1 | { 2 | "true": {}, 3 | "false": {}, 4 | "inf": {}, 5 | "nan": {} 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/keyword.toml: -------------------------------------------------------------------------------- 1 | [true] 2 | 3 | [false] 4 | 5 | [inf] 6 | 7 | [nan] 8 | 9 | 10 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-9.toml: -------------------------------------------------------------------------------- 1 | str7 = """"This," she said, "is just a pointless statement."""" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic.toml: -------------------------------------------------------------------------------- 1 | str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-3.toml: -------------------------------------------------------------------------------- 1 | quot15 = '''Here are fifteen quotation marks: """""""""""""""''' 2 | -------------------------------------------------------------------------------- /spec-tests/errors/inline-table-imutable-1.toml: -------------------------------------------------------------------------------- 1 | [product] 2 | type = { name = "Nail" } 3 | type.edible = false # INVALID 4 | -------------------------------------------------------------------------------- /spec-tests/errors/inline-table-imutable-2.toml: -------------------------------------------------------------------------------- 1 | [product] 2 | type.name = "Nail" 3 | type = { edible = false } # INVALID 4 | -------------------------------------------------------------------------------- /spec-tests/errors/table-1.toml: -------------------------------------------------------------------------------- 1 | # DO NOT DO THIS 2 | 3 | [fruit] 4 | apple = "red" 5 | 6 | [fruit] 7 | orange = "orange" 8 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/text-in-array.toml: -------------------------------------------------------------------------------- 1 | array = [ 2 | "Entry 1", 3 | I don't belong, 4 | "Entry 2", 5 | ] 6 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/minute-over.toml: -------------------------------------------------------------------------------- 1 | # time-minute = 2DIGIT ; 00-59 2 | d = 2006-01-01T00:60:00-00:00 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/month-under.toml: -------------------------------------------------------------------------------- 1 | # date-month = 2DIGIT ; 01-12 2 | d = 2007-00-01T00:00:00-00:00 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/duplicate-key-table.toml: -------------------------------------------------------------------------------- 1 | [fruit] 2 | type = "apple" 3 | 4 | [fruit.type] 5 | apple = "yes" 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nested-inline-table.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": [ 3 | { 4 | "b": {} 5 | } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/string-quote-comma.toml: -------------------------------------------------------------------------------- 1 | title = [ 2 | "Client: \"XXXX\", Job: XXXX", 3 | "Code: XXXX" 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/at-eof.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "type": "string", 4 | "value": "value" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/end-in-bool.toml: -------------------------------------------------------------------------------- 1 | black = { python=">3.6", version=">=18.9b0", allow_prereleases=true } 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "answer": { 3 | "type": "string", 4 | "value": "" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment.toml: -------------------------------------------------------------------------------- 1 | # This is a full-line comment 2 | key = "value" # This is a comment at the end of a line 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment.yaml: -------------------------------------------------------------------------------- 1 | # This is a full-line comment 2 | key: "value" # This is a comment at the end of a line 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-8.toml: -------------------------------------------------------------------------------- 1 | str6 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\".""" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-time-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "lt1": { 3 | "type": "time", 4 | "value": "07:32:00.000" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-time-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "lt2": { 3 | "type": "time", 4 | "value": "00:32:00.999" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/errors/string-literal-multiline-quotes.toml: -------------------------------------------------------------------------------- 1 | apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID 2 | -------------------------------------------------------------------------------- /spec-tests/errors/table-3.toml: -------------------------------------------------------------------------------- 1 | [fruit] 2 | apple.color = "red" 3 | apple.taste.sweet = true 4 | 5 | [fruit.apple] # INVALID 6 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/duplicate-key.toml: -------------------------------------------------------------------------------- 1 | # Duplicate keys within an inline table are invalid 2 | a={b=1, b=2} 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/at-eof2.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "type": "string", 4 | "value": "value" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/equals-nospace.json: -------------------------------------------------------------------------------- 1 | { 2 | "answer": { 3 | "type": "integer", 4 | "value": "42" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-local-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "ld1": { 3 | "type": "date", 4 | "value": "1979-05-27" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-5.toml: -------------------------------------------------------------------------------- 1 | ml-escaped-nl = """ 2 | foo \ 3 | bar \\ 4 | baz \\\ 5 | quux""" 6 | -------------------------------------------------------------------------------- /spec-tests/errors/table-4.toml: -------------------------------------------------------------------------------- 1 | [fruit] 2 | apple.color = "red" 3 | apple.taste.sweet = true 4 | 5 | [fruit.apple.taste] # INVALID 6 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/string/bad-codepoint.toml: -------------------------------------------------------------------------------- 1 | invalid-codepoint = "This string contains a non scalar unicode codepoint \uD801" 2 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/at-eof.toml: -------------------------------------------------------------------------------- 1 | # This is a full-line comment 2 | key = "value" # This is a comment at the end of a line 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/at-eof2.toml: -------------------------------------------------------------------------------- 1 | # This is a full-line comment 2 | key = "value" # This is a comment at the end of a line 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/special-word.toml: -------------------------------------------------------------------------------- 1 | false = false 2 | true = 1 3 | inf = 100000000 4 | nan = "ceci n'est pas un nombre" 5 | 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/escaped-escape.json: -------------------------------------------------------------------------------- 1 | { 2 | "answer": { 3 | "type": "string", 4 | "value": "\\x64" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/unicode-literal.json: -------------------------------------------------------------------------------- 1 | { 2 | "answer": { 3 | "type": "string", 4 | "value": "δ" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/errors/table-2.toml: -------------------------------------------------------------------------------- 1 | # DO NOT DO THIS EITHER 2 | 3 | [fruit] 4 | apple = "red" 5 | 6 | [fruit.apple] 7 | texture = "smooth" 8 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/encoding/utf16-bom.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komkom/toml/HEAD/spec-tests/tests/invalid/encoding/utf16-bom.toml -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/local.toml: -------------------------------------------------------------------------------- 1 | local = 1987-07-05T17:45:00 2 | milli = 1977-12-21T10:32:00.555 3 | space = 1987-07-05 17:45:00 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/double-quote-escape.json: -------------------------------------------------------------------------------- 1 | { 2 | "test": { 3 | "type": "string", 4 | "value": "\"one\"" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/text-after-array-entries.toml: -------------------------------------------------------------------------------- 1 | array = [ 2 | "Is there life after an array separator?", No 3 | "Entry" 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/no-leads.toml: -------------------------------------------------------------------------------- 1 | # Month "7" instead of "07"; the leading zero is required. 2 | no-leads = 1987-7-05T17:45:00Z 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/linebreak-4.toml: -------------------------------------------------------------------------------- 1 | json_like = { 2 | first = "Tom", 3 | last = "Preston-Werner" 4 | } 5 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/key/dotted-redefine-table.toml: -------------------------------------------------------------------------------- 1 | # Defined a.b as int 2 | a.b = 1 3 | # Tries to access it as table: error 4 | a.b.c = 2 5 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/redefine.toml: -------------------------------------------------------------------------------- 1 | # Define b as int, and try to use it as a table: error 2 | [a] 3 | b = 1 4 | 5 | [a.b] 6 | c = 2 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/example.toml: -------------------------------------------------------------------------------- 1 | best-day-ever = 1987-07-05T17:45:00Z 2 | 3 | [numtheory] 4 | boring = false 5 | perfection = [6, 28, 496] 6 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-2.toml: -------------------------------------------------------------------------------- 1 | str = """ 2 | The quick brown \ 3 | 4 | 5 | fox jumps over \ 6 | the lazy dog.""" 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-1.yaml: -------------------------------------------------------------------------------- 1 | table-1: 2 | key1: "some string" 3 | key2: 123 4 | table-2: 5 | key1: "another string" 6 | key2: 456 7 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/text-before-array-separator.toml: -------------------------------------------------------------------------------- 1 | array = [ 2 | "Is there life before an array separator?" No, 3 | "Entry" 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/local-date.json: -------------------------------------------------------------------------------- 1 | { 2 | "bestdayever": { 3 | "type": "date-local", 4 | "value": "1987-07-05" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-dotted-keys-1.toml: -------------------------------------------------------------------------------- 1 | name = "Orange" 2 | physical.color = "orange" 3 | physical.shape = "round" 4 | site."google.com" = true 5 | -------------------------------------------------------------------------------- /spec-tests/values/spec-dotted-keys-1.yaml: -------------------------------------------------------------------------------- 1 | name: "Orange" 2 | physical: 3 | color: "orange" 4 | shape: "round" 5 | site: 6 | "google.com": true 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-1.toml: -------------------------------------------------------------------------------- 1 | [table-1] 2 | key1 = "some string" 3 | key2 = 123 4 | 5 | [table-2] 6 | key1 = "another string" 7 | key2 = 456 8 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/komkom/toml 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/pkg/errors v0.9.1 7 | github.com/stretchr/testify v1.6.1 8 | ) 9 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/encoding/bad-utf8-at-end.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komkom/toml/HEAD/spec-tests/tests/invalid/encoding/bad-utf8-at-end.toml -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/overwrite.toml: -------------------------------------------------------------------------------- 1 | a.b=0 2 | # Since table "a" is already defined, it can't be replaced by an inline table. 3 | a={} 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/multiline.toml: -------------------------------------------------------------------------------- 1 | tbl_multiline = { a = 1, b = """ 2 | multiline 3 | """, c = """and yet 4 | another line""", d = 4 } 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/numeric-dotted.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "2": { 4 | "type": "integer", 5 | "value": "3" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-of-tables-3.yaml: -------------------------------------------------------------------------------- 1 | points: [ { x: 1, y: 2, z: 3 }, 2 | { x: 7, y: 8, z: 9 }, 3 | { x: 2, y: 4, z: 8 } ] 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-local-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "ldt1": { 3 | "type": "datetime-local", 4 | "value": "1979-05-27T07:32:00.000" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-date-time-local-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "ldt2": { 3 | "type": "datetime-local", 4 | "value": "1979-05-27T00:32:00.999" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-2.yaml: -------------------------------------------------------------------------------- 1 | lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n" 2 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-8.yaml: -------------------------------------------------------------------------------- 1 | fruit: 2 | apple: 3 | color: "red" 4 | taste: 5 | sweet: true 6 | texture: 7 | smooth: true 8 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/no-leads-with-milli.toml: -------------------------------------------------------------------------------- 1 | # Day "5" instead of "05"; the leading zero is required. 2 | with-milli = 1987-07-5T17:45:00.12Z 3 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/encoding/bad-utf8-in-comment.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komkom/toml/HEAD/spec-tests/tests/invalid/encoding/bad-utf8-in-comment.toml -------------------------------------------------------------------------------- /spec-tests/tests/invalid/encoding/bad-utf8-in-string.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komkom/toml/HEAD/spec-tests/tests/invalid/encoding/bad-utf8-in-string.toml -------------------------------------------------------------------------------- /spec-tests/tests/invalid/encoding/bom-not-at-start-1.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komkom/toml/HEAD/spec-tests/tests/invalid/encoding/bom-not-at-start-1.toml -------------------------------------------------------------------------------- /spec-tests/tests/invalid/encoding/bom-not-at-start-2.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komkom/toml/HEAD/spec-tests/tests/invalid/encoding/bom-not-at-start-2.toml -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "answer": { 3 | "type": "string", 4 | "value": "You are not drinking enough whisky." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-basic-multiline-3.toml: -------------------------------------------------------------------------------- 1 | str = """\ 2 | The quick brown \ 3 | fox jumps over \ 4 | the lazy dog.\ 5 | """ 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/string-quote-comma-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": [ 3 | { 4 | "type": "string", 5 | "value": " \", " 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/with-pound.toml: -------------------------------------------------------------------------------- 1 | pound = "We see no # comments here." 2 | poundcomment = "But there are # some comments here." # Did I # mess you up? 3 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/with-pound.json: -------------------------------------------------------------------------------- 1 | { 2 | "key#group": { 3 | "answer": { 4 | "type": "integer", 5 | "value": "42" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/without-super.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": { 3 | "y": { 4 | "z": { 5 | "w": {} 6 | } 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-of-tables-3.toml: -------------------------------------------------------------------------------- 1 | points = [ { x = 1, y = 2, z = 3 }, 2 | { x = 7, y = 8, z = 9 }, 3 | { x = 2, y = 4, z = 8 } ] 4 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-of-tables-1.yaml: -------------------------------------------------------------------------------- 1 | products: [ 2 | {name: "Hammer", sku: 738594937}, 3 | {}, 4 | {name: "Nail", sku: 284758393, color: "gray" } 5 | ] 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/special-chars.json: -------------------------------------------------------------------------------- 1 | { 2 | "~!@$^\u0026*()_+-`1234567890[]|/?\u003e\u003c.,;:'": { 3 | "type": "integer", 4 | "value": "1" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/nl.toml: -------------------------------------------------------------------------------- 1 | nl_mid = "val\nue" 2 | nl_end = """value\n""" 3 | 4 | lit_nl_end = '''value\n''' 5 | lit_nl_mid = 'val\nue' 6 | lit_nl_uni = 'val\ue' 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/names.toml: -------------------------------------------------------------------------------- 1 | [a.b.c] 2 | [a."b.c"] 3 | [a.'d.e'] 4 | [a.' x '] 5 | [ d.e.f ] 6 | [ g . h . i ] 7 | [ j . "ʞ" . 'l' ] 8 | 9 | [x.1.2] 10 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-7.toml: -------------------------------------------------------------------------------- 1 | # [x] you 2 | # [x.y] don't 3 | # [x.y.z] need these 4 | [x.y.z.w] # for this to work 5 | [x] # defining a super-table afterwards is ok 6 | -------------------------------------------------------------------------------- /spec-tests/values/spec-table-8.toml: -------------------------------------------------------------------------------- 1 | [fruit] 2 | apple.color = "red" 3 | apple.taste.sweet = true 4 | 5 | [fruit.apple.texture] # you can add sub-tables 6 | smooth = true 7 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/linebreak-1.toml: -------------------------------------------------------------------------------- 1 | # No newlines are allowed between the curly braces unless they are valid within 2 | # a value. 3 | simple = { a = 1 4 | } 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "thevoid": [ 3 | [ 4 | [ 5 | [ 6 | [] 7 | ] 8 | ] 9 | ] 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment-tab.toml: -------------------------------------------------------------------------------- 1 | # This is a full-line comment with a tab in the middle 2 | key = "value" # This is a commen with a tab in the middle at the end of a line 3 | -------------------------------------------------------------------------------- /spec-tests/values/spec-string-literal-multiline-2.toml: -------------------------------------------------------------------------------- 1 | lines = ''' 2 | The first newline is 3 | trimmed in raw strings. 4 | All other whitespace 5 | is preserved. 6 | ''' 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/exponent.toml: -------------------------------------------------------------------------------- 1 | lower = 3e2 2 | upper = 3E2 3 | neg = 3e-2 4 | pos = 3E+2 5 | zero = 3e0 6 | pointlower = 3.1e2 7 | pointupper = 3.1E2 8 | minustenth = -1E-1 9 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-table-array.toml: -------------------------------------------------------------------------------- 1 | [[a]] 2 | [[a.b]] 3 | [a.b.c] 4 | d = "val0" 5 | [[a.b]] 6 | [a.b.c] 7 | d = "val1" 8 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/without-super.toml: -------------------------------------------------------------------------------- 1 | # [x] you 2 | # [x.y] don't 3 | # [x.y.z] need these 4 | [x.y.z.w] # for this to work 5 | [x] # defining a super-table afterwards is ok 6 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment-mid-array.yaml: -------------------------------------------------------------------------------- 1 | # eol commetns can go anywhere 2 | abc: [ # this is valid 3 | 123,#as is this 4 | 456 #so is this 5 | ]# and this 6 | # here too 7 | -------------------------------------------------------------------------------- /spec-tests/values/spec-comment-mid-array.toml: -------------------------------------------------------------------------------- 1 | # eol commetns can go anywhere 2 | abc = [ # this is valid 3 | 123,#as is this 4 | 456 #so is this 5 | ]# and this 6 | # here too 7 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/mday-over.toml: -------------------------------------------------------------------------------- 1 | # date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on 2 | # ; month/year 3 | d = 2006-01-32T00:00:00-00:00 4 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/mday-under.toml: -------------------------------------------------------------------------------- 1 | # date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on 2 | # ; month/year 3 | d = 2006-01-00T00:00:00-00:00 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/timezone.toml: -------------------------------------------------------------------------------- 1 | utc = 1987-07-05T17:45:56Z 2 | pdt = 1987-07-05T17:45:56-05:00 3 | nzst = 1987-07-05T17:45:56+12:00 4 | nzdt = 1987-07-05T17:45:56+13:00 # DST 5 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/datetime/second-over.toml: -------------------------------------------------------------------------------- 1 | # time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second 2 | # ; rules 3 | d = 2006-01-01T00:00:61-00:00 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/bool/bool.json: -------------------------------------------------------------------------------- 1 | { 2 | "f": { 3 | "type": "bool", 4 | "value": "false" 5 | }, 6 | "t": { 7 | "type": "bool", 8 | "value": "true" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-more-mixed-types.toml: -------------------------------------------------------------------------------- 1 | contributors = [ 2 | "Foo Bar ", 3 | { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } 4 | ] -------------------------------------------------------------------------------- /spec-tests/values/spec-array-more-mixed-types.yaml: -------------------------------------------------------------------------------- 1 | contributors: [ 2 | "Foo Bar ", 3 | { name: "Baz Qux", email: "bazqux@example.com", url: "https://example.com/bazqux" } 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-string-table.toml: -------------------------------------------------------------------------------- 1 | contributors = [ 2 | "Foo Bar ", 3 | { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } 4 | ] 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/milliseconds.toml: -------------------------------------------------------------------------------- 1 | utc1 = 1987-07-05T17:45:56.1234Z 2 | utc2 = 1987-07-05T17:45:56.6Z 3 | wita1 = 1987-07-05T17:45:56.1234+08:00 4 | wita2 = 1987-07-05T17:45:56.6+08:00 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/zero.toml: -------------------------------------------------------------------------------- 1 | zero = 0.0 2 | signed-pos = +0.0 3 | signed-neg = -0.0 4 | exponent = 0e0 5 | exponent-two-0 = 0e00 6 | exponent-signed-pos = +0e0 7 | exponent-signed-neg = -0e0 8 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/quoted-dots.toml: -------------------------------------------------------------------------------- 1 | plain = 1 2 | "with.dot" = 2 3 | 4 | [plain_table] 5 | plain = 3 6 | "with.dot" = 4 7 | 8 | [table.withdot] 9 | plain = 5 10 | "key.with.dots" = 6 11 | -------------------------------------------------------------------------------- /spec-tests/values/spec-extend-dotted-object-2.yaml: -------------------------------------------------------------------------------- 1 | apple: 2 | type: "fruit" 3 | skin: "thin" 4 | color: "red" 5 | 6 | orange: 7 | type: "fruit" 8 | skin: "thick" 9 | color: "orange" 10 | -------------------------------------------------------------------------------- /spec-tests/values/spec-extend-dotted-object-3.yaml: -------------------------------------------------------------------------------- 1 | apple: 2 | type: "fruit" 3 | skin: "thin" 4 | color: "red" 5 | 6 | orange: 7 | type: "fruit" 8 | skin: "thick" 9 | color: "orange" 10 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/inline-table/trailing-comma.toml: -------------------------------------------------------------------------------- 1 | # A terminating comma (also called trailing comma) is not permitted after the 2 | # last key/value pair in an inline table 3 | abc = { abc = 123, } 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/newline-crlf.json: -------------------------------------------------------------------------------- 1 | { 2 | "newline": { 3 | "type": "string", 4 | "value": "crlf" 5 | }, 6 | "os": { 7 | "type": "string", 8 | "value": "DOS" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/newline-lf.json: -------------------------------------------------------------------------------- 1 | { 2 | "newline": { 3 | "type": "string", 4 | "value": "lf" 5 | }, 6 | "os": { 7 | "type": "string", 8 | "value": "unix" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/values/spec-extend-dotted-object-1.toml: -------------------------------------------------------------------------------- 1 | # This makes the key "fruit" into a table. 2 | fruit.apple.smooth = true 3 | 4 | # So then you can add to the table "fruit" like so: 5 | fruit.orange = 2 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/underscore.json: -------------------------------------------------------------------------------- 1 | { 2 | "kilo": { 3 | "type": "integer", 4 | "value": "1000" 5 | }, 6 | "x": { 7 | "type": "integer", 8 | "value": "1111" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-of-tables-1.toml: -------------------------------------------------------------------------------- 1 | [[products]] 2 | name = "Hammer" 3 | sku = 738594937 4 | 5 | [[products]] 6 | 7 | [[products]] 8 | name = "Nail" 9 | sku = 284758393 10 | color = "gray" 11 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/trailing-us-exp.toml: -------------------------------------------------------------------------------- 1 | # trailing underscore in integer part is not allowed 2 | trailing-us-exp = 1_e2 3 | # trailing underscore in float part is not allowed 4 | trailing-us-exp2 = 1.2_e2 5 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/unicode-escape.json: -------------------------------------------------------------------------------- 1 | { 2 | "answer4": { 3 | "type": "string", 4 | "value": "δ" 5 | }, 6 | "answer8": { 7 | "type": "string", 8 | "value": "δ" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/table-array-string-backslash.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": [ 3 | { 4 | "bar": { 5 | "type": "string", 6 | "value": "\"{{baz}}\"" 7 | } 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/array.toml: -------------------------------------------------------------------------------- 1 | people = [{first_name = "Bruce", last_name = "Springsteen"}, 2 | {first_name = "Eric", last_name = "Clapton"}, 3 | {first_name = "Bob", last_name = "Seger"}] 4 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/empty.toml: -------------------------------------------------------------------------------- 1 | empty1 = {} 2 | empty2 = { } 3 | empty_in_array = [ { not_empty = 1 }, {} ] 4 | empty_in_array2 = [{},{not_empty=1}] 5 | many_empty = [{},{},{}] 6 | nested_empty = {"empty"={}} 7 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/bool.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": [ 3 | { 4 | "type": "bool", 5 | "value": "true" 6 | }, 7 | { 8 | "type": "bool", 9 | "value": "false" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/inline-table.toml: -------------------------------------------------------------------------------- 1 | name = { first = "Tom", last = "Preston-Werner" } 2 | point = { x = 1, y = 2 } 3 | simple = { a = 1 } 4 | str-key = { "a" = 1 } 5 | table-array = [{ "a" = 1 }, { "b" = 2 }] 6 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/zero.toml: -------------------------------------------------------------------------------- 1 | d1 = 0 2 | d2 = +0 3 | d3 = -0 4 | 5 | h1 = 0x0 6 | h2 = 0x00 7 | h3 = 0x00000 8 | 9 | o1 = 0o0 10 | a2 = 0o00 11 | a3 = 0o00000 12 | 13 | b1 = 0b0 14 | b2 = 0b00 15 | b3 = 0b00000 16 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/long.json: -------------------------------------------------------------------------------- 1 | { 2 | "longpi": { 3 | "type": "float", 4 | "value": "3.141592653589793" 5 | }, 6 | "neglongpi": { 7 | "type": "float", 8 | "value": "-3.141592653589793" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/implicit-groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "b": { 4 | "c": { 5 | "answer": { 6 | "type": "integer", 7 | "value": "42" 8 | } 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/escapes.toml: -------------------------------------------------------------------------------- 1 | "\n" = "newline" 2 | "\u00c0" = "latin capital letter A with grave" 3 | "\"" = "just a quote" 4 | 5 | ["backsp\b\b"] 6 | 7 | ["\"quoted\""] 8 | quote = true 9 | 10 | ["a.b"."\u00c0"] 11 | -------------------------------------------------------------------------------- /spec-tests/values/spec-extend-dotted-object-3.toml: -------------------------------------------------------------------------------- 1 | # RECOMMENDED 2 | 3 | apple.type = "fruit" 4 | apple.skin = "thin" 5 | apple.color = "red" 6 | 7 | orange.type = "fruit" 8 | orange.skin = "thick" 9 | orange.color = "orange" 10 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/bool.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "a": { 4 | "type": "bool", 5 | "value": "true" 6 | }, 7 | "b": { 8 | "type": "bool", 9 | "value": "false" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/literals.toml: -------------------------------------------------------------------------------- 1 | bin1 = 0b11010110 2 | bin2 = 0b1_0_1 3 | 4 | oct1 = 0o01234567 5 | oct2 = 0o755 6 | oct3 = 0o7_6_5 7 | 8 | hex1 = 0xDEADBEEF 9 | hex2 = 0xdeadbeef 10 | hex3 = 0xdead_beef 11 | hex4 = 0x00987 12 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/with-single-quotes.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "b": { 4 | "c": { 5 | "answer": { 6 | "type": "integer", 7 | "value": "42" 8 | } 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-int-float.json: -------------------------------------------------------------------------------- 1 | { 2 | "ints-and-floats": [ 3 | { 4 | "type": "integer", 5 | "value": "1" 6 | }, 7 | { 8 | "type": "float", 9 | "value": "1.1" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-int-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "strings-and-ints": [ 3 | { 4 | "type": "string", 5 | "value": "hi" 6 | }, 7 | { 8 | "type": "integer", 9 | "value": "42" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/datetime.json: -------------------------------------------------------------------------------- 1 | { 2 | "lower": { 3 | "type": "datetime", 4 | "value": "1987-07-05T17:45:00Z" 5 | }, 6 | "space": { 7 | "type": "datetime", 8 | "value": "1987-07-05T17:45:00Z" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/local-time.json: -------------------------------------------------------------------------------- 1 | { 2 | "besttimeever": { 3 | "type": "time-local", 4 | "value": "17:45:00" 5 | }, 6 | "milliseconds": { 7 | "type": "time-local", 8 | "value": "10:32:00.555" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-implicit.json: -------------------------------------------------------------------------------- 1 | { 2 | "albums": { 3 | "songs": [ 4 | { 5 | "name": { 6 | "type": "string", 7 | "value": "Glory Days" 8 | } 9 | } 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/with-literal-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "\"b\"": { 4 | "c": { 5 | "answer": { 6 | "type": "integer", 7 | "value": "42" 8 | } 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/values/spec-extend-dotted-object-2.toml: -------------------------------------------------------------------------------- 1 | # VALID BUT DISCOURAGED 2 | 3 | apple.type = "fruit" 4 | orange.type = "fruit" 5 | 6 | apple.skin = "thin" 7 | orange.skin = "thick" 8 | 9 | apple.color = "red" 10 | orange.color = "orange" 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/long.json: -------------------------------------------------------------------------------- 1 | { 2 | "int64-max": { 3 | "type": "integer", 4 | "value": "9223372036854775807" 5 | }, 6 | "int64-max-neg": { 7 | "type": "integer", 8 | "value": "-9223372036854775808" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-many.toml: -------------------------------------------------------------------------------- 1 | [[people]] 2 | first_name = "Bruce" 3 | last_name = "Springsteen" 4 | 5 | [[people]] 6 | first_name = "Eric" 7 | last_name = "Clapton" 8 | 9 | [[people]] 10 | first_name = "Bob" 11 | last_name = "Seger" 12 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/string-with-comma.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": [ 3 | { 4 | "type": "string", 5 | "value": "Client: XXXX, Job: XXXX" 6 | }, 7 | { 8 | "type": "string", 9 | "value": "Code: XXXX" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/errors/array-of-tables-2.toml: -------------------------------------------------------------------------------- 1 | # INVALID TOML DOC 2 | [[fruit]] 3 | name = "apple" 4 | 5 | [[fruit.variety]] 6 | name = "red delicious" 7 | 8 | # This table conflicts with the previous table 9 | [fruit.variety] 10 | name = "granny smith" 11 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/array/tables-2.toml: -------------------------------------------------------------------------------- 1 | # INVALID TOML DOC 2 | [[fruit]] 3 | name = "apple" 4 | 5 | [[fruit.variety]] 6 | name = "red delicious" 7 | 8 | # This table conflicts with the previous table 9 | [fruit.variety] 10 | name = "granny smith" 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/string-quote-comma.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": [ 3 | { 4 | "type": "string", 5 | "value": "Client: \"XXXX\", Job: XXXX" 6 | }, 7 | { 8 | "type": "string", 9 | "value": "Code: XXXX" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/with-pound.json: -------------------------------------------------------------------------------- 1 | { 2 | "pound": { 3 | "type": "string", 4 | "value": "We see no # comments here." 5 | }, 6 | "poundcomment": { 7 | "type": "string", 8 | "value": "But there are # some comments here." 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/alphanum.toml: -------------------------------------------------------------------------------- 1 | alpha = "a" 2 | 123 = "num" 3 | 000111 = "leading" 4 | 10e3 = "false float" 5 | one1two2 = "mixed" 6 | with-dash = "dashed" 7 | under_score = "___" 8 | 34-11 = 23 9 | 10 | [2018_10] 11 | 001 = 1 12 | 13 | [a-a-a] 14 | _ = false 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nested.json: -------------------------------------------------------------------------------- 1 | { 2 | "nest": [ 3 | [ 4 | { 5 | "type": "string", 6 | "value": "a" 7 | } 8 | ], 9 | [ 10 | { 11 | "type": "string", 12 | "value": "b" 13 | } 14 | ] 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /spec-tests/errors/multiple-dot-key.toml: -------------------------------------------------------------------------------- 1 | # THE FOLLOWING IS INVALID 2 | 3 | # This defines the value of fruit.apple to be an integer. 4 | fruit.apple = 1 5 | 6 | # But then this treats fruit.apple like it's a table. 7 | # You can't turn an integer into a table. 8 | fruit.apple.smooth = true 9 | -------------------------------------------------------------------------------- /spec-tests/errors/table-invalid-1.toml: -------------------------------------------------------------------------------- 1 | [fruit.physical] # subtable, but to which parent element should it belong? 2 | color = "red" 3 | shape = "round" 4 | 5 | [[fruit]] # parser must throw an error upon discovering that "fruit" is 6 | # an array rather than a table 7 | name = "apple" -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/array.toml: -------------------------------------------------------------------------------- 1 | ints = [1, 2, 3, ] 2 | floats = [1.1, 2.1, 3.1] 3 | strings = ["a", "b", "c"] 4 | dates = [ 5 | 1987-07-05T17:45:00Z, 6 | 1979-05-27T07:32:00Z, 7 | 2006-06-01T11:00:00Z, 8 | ] 9 | comments = [ 10 | 1, 11 | 2, #this is ok 12 | ] 13 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-int-array.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrays-and-ints": [ 3 | { 4 | "type": "integer", 5 | "value": "1" 6 | }, 7 | [ 8 | { 9 | "type": "string", 10 | "value": "Arrays are not integers." 11 | } 12 | ] 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nospaces.json: -------------------------------------------------------------------------------- 1 | { 2 | "ints": [ 3 | { 4 | "type": "integer", 5 | "value": "1" 6 | }, 7 | { 8 | "type": "integer", 9 | "value": "2" 10 | }, 11 | { 12 | "type": "integer", 13 | "value": "3" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/inf-and-nan.toml: -------------------------------------------------------------------------------- 1 | # We don't encode +nan and -nan back with the signs; many languages don't 2 | # support a sign on NaN (it doesn't really make much sense). 3 | nan = nan 4 | nan_neg = -nan 5 | nan_plus = +nan 6 | infinity = inf 7 | infinity_neg = -inf 8 | infinity_plus = +inf 9 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/underscore.json: -------------------------------------------------------------------------------- 1 | { 2 | "after": { 3 | "type": "float", 4 | "value": "3141.5927" 5 | }, 6 | "before": { 7 | "type": "float", 8 | "value": "3141.5927" 9 | }, 10 | "exponent": { 11 | "type": "float", 12 | "value": "3.0e14" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/case-sensitive.toml: -------------------------------------------------------------------------------- 1 | sectioN = "NN" 2 | 3 | [section] 4 | name = "lower" 5 | NAME = "upper" 6 | Name = "capitalized" 7 | 8 | [Section] 9 | name = "different section!!" 10 | "μ" = "greek small letter mu" 11 | "Μ" = "greek capital letter MU" 12 | M = "latin letter M" 13 | 14 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-one.json: -------------------------------------------------------------------------------- 1 | { 2 | "people": [ 3 | { 4 | "first_name": { 5 | "type": "string", 6 | "value": "Bruce" 7 | }, 8 | "last_name": { 9 | "type": "string", 10 | "value": "Springsteen" 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/implicit-and-explicit-after.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "b": { 4 | "c": { 5 | "answer": { 6 | "type": "integer", 7 | "value": "42" 8 | } 9 | } 10 | }, 11 | "better": { 12 | "type": "integer", 13 | "value": "43" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/implicit-and-explicit-before.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "b": { 4 | "c": { 5 | "answer": { 6 | "type": "integer", 7 | "value": "42" 8 | } 9 | } 10 | }, 11 | "better": { 12 | "type": "integer", 13 | "value": "43" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/append-with-dotted-keys-2.toml: -------------------------------------------------------------------------------- 1 | # This is the same issue as in injection-1.toml, except that nests one level 2 | # deeper. See that file for a more complete description. 3 | 4 | [a.b.c.d] 5 | z = 9 6 | 7 | [a] 8 | b.c.d.k.t = "Using dotted keys to add to [a.b.c.d] after explicitly defining it above is not allowed" 9 | -------------------------------------------------------------------------------- /spec-tests/errors/table-invalid-4.toml: -------------------------------------------------------------------------------- 1 | # INVALID TOML DOC 2 | [[fruit]] 3 | name = "apple" 4 | 5 | [[fruit.variety]] 6 | name = "red delicious" 7 | 8 | [fruit.physical] 9 | color = "red" 10 | shape = "round" 11 | 12 | # INVALID: This array of tables conflicts with the previous table 13 | [[fruit.physical]] 14 | color = "green" 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/local.json: -------------------------------------------------------------------------------- 1 | { 2 | "local": { 3 | "type": "datetime-local", 4 | "value": "1987-07-05T17:45:00" 5 | }, 6 | "milli": { 7 | "type": "datetime-local", 8 | "value": "1977-12-21T10:32:00.555" 9 | }, 10 | "space": { 11 | "type": "datetime-local", 12 | "value": "1987-07-05T17:45:00" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spec-tests/errors/table-invalid-3.toml: -------------------------------------------------------------------------------- 1 | # INVALID TOML DOC 2 | [[fruit]] 3 | name = "apple" 4 | 5 | [[fruit.variety]] 6 | name = "red delicious" 7 | 8 | # INVALID: This table conflicts with the previous array of tables 9 | [fruit.variety] 10 | name = "granny smith" 11 | 12 | [fruit.physical] 13 | color = "red" 14 | shape = "round" 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/float.json: -------------------------------------------------------------------------------- 1 | { 2 | "negpi": { 3 | "type": "float", 4 | "value": "-3.14" 5 | }, 6 | "pi": { 7 | "type": "float", 8 | "value": "3.14" 9 | }, 10 | "pospi": { 11 | "type": "float", 12 | "value": "3.14" 13 | }, 14 | "zero-intpart": { 15 | "type": "float", 16 | "value": "0.123" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "answer": { 3 | "type": "integer", 4 | "value": "42" 5 | }, 6 | "neganswer": { 7 | "type": "integer", 8 | "value": "-42" 9 | }, 10 | "posanswer": { 11 | "type": "integer", 12 | "value": "42" 13 | }, 14 | "zero": { 15 | "type": "integer", 16 | "value": "0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/end-in-bool.json: -------------------------------------------------------------------------------- 1 | { 2 | "black": { 3 | "allow_prereleases": { 4 | "type": "bool", 5 | "value": "true" 6 | }, 7 | "python": { 8 | "type": "string", 9 | "value": "\u003e3.6" 10 | }, 11 | "version": { 12 | "type": "string", 13 | "value": "\u003e=18.9b0" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-of-tables-2.toml: -------------------------------------------------------------------------------- 1 | [[fruit]] 2 | name = "apple" 3 | 4 | [fruit.physical] 5 | color = "red" 6 | shape = "round" 7 | 8 | [[fruit.variety]] 9 | name = "red delicious" 10 | 11 | [[fruit.variety]] 12 | name = "granny smith" 13 | 14 | [[fruit]] 15 | name = "banana" 16 | 17 | [[fruit.variety]] 18 | name = "plantain" 19 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-nest.toml: -------------------------------------------------------------------------------- 1 | [[albums]] 2 | name = "Born to Run" 3 | 4 | [[albums.songs]] 5 | name = "Jungleland" 6 | 7 | [[albums.songs]] 8 | name = "Meeting Across the River" 9 | 10 | [[albums]] 11 | name = "Born in the USA" 12 | 13 | [[albums.songs]] 14 | name = "Glory Days" 15 | 16 | [[albums.songs]] 17 | name = "Dancing in the Dark" 18 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/special-word.json: -------------------------------------------------------------------------------- 1 | { 2 | "false": { 3 | "type": "bool", 4 | "value": "false" 5 | }, 6 | "inf": { 7 | "type": "integer", 8 | "value": "100000000" 9 | }, 10 | "nan": { 11 | "type": "string", 12 | "value": "ceci n'est pas un nombre" 13 | }, 14 | "true": { 15 | "type": "integer", 16 | "value": "1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spec-tests/values/spec-array-of-tables-2.yaml: -------------------------------------------------------------------------------- 1 | fruit: [ 2 | { 3 | name: "apple", 4 | physical: { 5 | color: "red", 6 | shape: "round" 7 | }, 8 | variety: [ 9 | { name: "red delicious" }, 10 | { name: "granny smith" } 11 | ] 12 | }, 13 | { 14 | name: "banana", 15 | variety: [ 16 | { name: "plantain" } 17 | ] 18 | } 19 | ] 20 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/strings.json: -------------------------------------------------------------------------------- 1 | { 2 | "string_array": [ 3 | { 4 | "type": "string", 5 | "value": "all" 6 | }, 7 | { 8 | "type": "string", 9 | "value": "strings" 10 | }, 11 | { 12 | "type": "string", 13 | "value": "are the same" 14 | }, 15 | { 16 | "type": "string", 17 | "value": "type" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/raw-multiline.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstnl": { 3 | "type": "string", 4 | "value": "This string has a ' quote character." 5 | }, 6 | "multiline": { 7 | "type": "string", 8 | "value": "This string\nhas ' a quote character\nand more than\none newline\nin it." 9 | }, 10 | "oneline": { 11 | "type": "string", 12 | "value": "This string has a ' quote character." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/raw.toml: -------------------------------------------------------------------------------- 1 | backspace = 'This string has a \b backspace character.' 2 | tab = 'This string has a \t tab character.' 3 | newline = 'This string has a \n new line character.' 4 | formfeed = 'This string has a \f form feed character.' 5 | carriage = 'This string has a \r carriage return character.' 6 | slash = 'This string has a \/ slash character.' 7 | backslash = 'This string has a \\ backslash character.' 8 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/escape-tricky.toml: -------------------------------------------------------------------------------- 1 | end_esc = "String does not end here\" but ends here\\" 2 | lit_end_esc = 'String ends here\' 3 | 4 | multiline_unicode = """ 5 | \u00a0""" 6 | 7 | multiline_not_unicode = """ 8 | \\u0041""" 9 | 10 | multiline_end_esc = """When will it end? \"""...""\" should be here\"""" 11 | 12 | lit_multiline_not_unicode = ''' 13 | \u007f''' 14 | 15 | lit_multiline_end = '''There is no escape\''' 16 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/multiline.json: -------------------------------------------------------------------------------- 1 | { 2 | "tbl_multiline": { 3 | "a": { 4 | "type": "integer", 5 | "value": "1" 6 | }, 7 | "b": { 8 | "type": "string", 9 | "value": "multiline\n" 10 | }, 11 | "c": { 12 | "type": "string", 13 | "value": "and yet\nanother line" 14 | }, 15 | "d": { 16 | "type": "integer", 17 | "value": "4" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/timezone.json: -------------------------------------------------------------------------------- 1 | { 2 | "nzdt": { 3 | "type": "datetime", 4 | "value": "1987-07-05T17:45:56+13:00" 5 | }, 6 | "nzst": { 7 | "type": "datetime", 8 | "value": "1987-07-05T17:45:56+12:00" 9 | }, 10 | "pdt": { 11 | "type": "datetime", 12 | "value": "1987-07-05T17:45:56-05:00" 13 | }, 14 | "utc": { 15 | "type": "datetime", 16 | "value": "1987-07-05T17:45:56Z" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/names.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | " x ": {}, 4 | "b": { 5 | "c": {} 6 | }, 7 | "b.c": {}, 8 | "d.e": {} 9 | }, 10 | "d": { 11 | "e": { 12 | "f": {} 13 | } 14 | }, 15 | "g": { 16 | "h": { 17 | "i": {} 18 | } 19 | }, 20 | "j": { 21 | "ʞ": { 22 | "l": {} 23 | } 24 | }, 25 | "x": { 26 | "1": { 27 | "2": {} 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/nest.toml: -------------------------------------------------------------------------------- 1 | tbl_tbl_empty = { tbl_0 = {} } 2 | tbl_tbl_val = { tbl_1 = { one = 1 } } 3 | tbl_arr_tbl = { arr_tbl = [ { one = 1 } ] } 4 | arr_tbl_tbl = [ { tbl = { one = 1 } } ] 5 | 6 | # Array-of-array-of-table is interesting because it can only 7 | # be represented in inline form. 8 | arr_arr_tbl_empty = [ [ {} ] ] 9 | arr_arr_tbl_val = [ [ { one = 1 } ] ] 10 | arr_arr_tbls = [ [ { one = 1 }, { two = 2 } ] ] 11 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/key-dotted.toml: -------------------------------------------------------------------------------- 1 | inline = {a.b = 42} 2 | 3 | many.dots.here.dot.dot.dot = {a.b.c = 1, a.b.d = 2} 4 | 5 | a = { a.b = 1 } 6 | b = { "a"."b" = 1 } 7 | c = { a . b = 1 } 8 | d = { 'a' . "b" = 1 } 9 | e = {a.b=1} 10 | 11 | [tbl] 12 | a.b.c = {d.e=1} 13 | 14 | [tbl.x] 15 | a.b.c = {d.e=1} 16 | 17 | [[arr]] 18 | t = {a.b=1} 19 | T = {a.b=1} 20 | 21 | [[arr]] 22 | t = {a.b=2} 23 | T = {a.b=2} 24 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/datetime/milliseconds.json: -------------------------------------------------------------------------------- 1 | { 2 | "utc1": { 3 | "type": "datetime", 4 | "value": "1987-07-05T17:45:56.1234Z" 5 | }, 6 | "utc2": { 7 | "type": "datetime", 8 | "value": "1987-07-05T17:45:56.6000Z" 9 | }, 10 | "wita1": { 11 | "type": "datetime", 12 | "value": "1987-07-05T17:45:56.1234+08:00" 13 | }, 14 | "wita2": { 15 | "type": "datetime", 16 | "value": "1987-07-05T17:45:56.6000+08:00" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/raw-multiline.toml: -------------------------------------------------------------------------------- 1 | # Single ' should be allowed. 2 | oneline = '''This string has a ' quote character.''' 3 | 4 | # A newline immediately following the opening delimiter will be trimmed. 5 | firstnl = ''' 6 | This string has a ' quote character.''' 7 | 8 | # All other whitespace and newline characters remain intact. 9 | multiline = ''' 10 | This string 11 | has ' a quote character 12 | and more than 13 | one newline 14 | in it.''' 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/nl.json: -------------------------------------------------------------------------------- 1 | { 2 | "lit_nl_end": { 3 | "type": "string", 4 | "value": "value\\n" 5 | }, 6 | "lit_nl_mid": { 7 | "type": "string", 8 | "value": "val\\nue" 9 | }, 10 | "lit_nl_uni": { 11 | "type": "string", 12 | "value": "val\\ue" 13 | }, 14 | "nl_end": { 15 | "type": "string", 16 | "value": "value\n" 17 | }, 18 | "nl_mid": { 19 | "type": "string", 20 | "value": "val\nue" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: Go 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Set up Go 17 | uses: actions/setup-go@v2 18 | with: 19 | go-version: 1.17 20 | 21 | - name: Build 22 | run: go build -v ./... 23 | 24 | - name: Test 25 | run: go test -v ./... 26 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-table-array.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": [ 3 | { 4 | "b": [ 5 | { 6 | "c": { 7 | "d": { 8 | "type": "string", 9 | "value": "val0" 10 | } 11 | } 12 | }, 13 | { 14 | "c": { 15 | "d": { 16 | "type": "string", 17 | "value": "val1" 18 | } 19 | } 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/escapes.json: -------------------------------------------------------------------------------- 1 | { 2 | "\n": { 3 | "type": "string", 4 | "value": "newline" 5 | }, 6 | "\"": { 7 | "type": "string", 8 | "value": "just a quote" 9 | }, 10 | "\"quoted\"": { 11 | "quote": { 12 | "type": "bool", 13 | "value": "true" 14 | } 15 | }, 16 | "a.b": { 17 | "À": {} 18 | }, 19 | "backsp\u0008\u0008": {}, 20 | "À": { 21 | "type": "string", 22 | "value": "latin capital letter A with grave" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/spec-example-1-compact.toml: -------------------------------------------------------------------------------- 1 | #Useless spaces eliminated. 2 | title="TOML Example" 3 | [owner] 4 | name="Lance Uppercut" 5 | dob=1979-05-27T07:32:00-08:00#First class dates 6 | [database] 7 | server="192.168.1.1" 8 | ports=[8001,8001,8002] 9 | connection_max=5000 10 | enabled=true 11 | [servers] 12 | [servers.alpha] 13 | ip="10.0.0.1" 14 | dc="eqdc10" 15 | [servers.beta] 16 | ip="10.0.0.2" 17 | dc="eqdc10" 18 | [clients] 19 | data=[["gamma","delta"],[1,2]] 20 | hosts=[ 21 | "alpha", 22 | "omega" 23 | ] 24 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/inf-and-nan.json: -------------------------------------------------------------------------------- 1 | { 2 | "infinity": { 3 | "type": "float", 4 | "value": "inf" 5 | }, 6 | "infinity_neg": { 7 | "type": "float", 8 | "value": "-inf" 9 | }, 10 | "infinity_plus": { 11 | "type": "float", 12 | "value": "+inf" 13 | }, 14 | "nan": { 15 | "type": "float", 16 | "value": "nan" 17 | }, 18 | "nan_neg": { 19 | "type": "float", 20 | "value": "nan" 21 | }, 22 | "nan_plus": { 23 | "type": "float", 24 | "value": "nan" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/mixed-string-table.json: -------------------------------------------------------------------------------- 1 | { 2 | "contributors": [ 3 | { 4 | "type": "string", 5 | "value": "Foo Bar \u003cfoo@example.com\u003e" 6 | }, 7 | { 8 | "email": { 9 | "type": "string", 10 | "value": "bazqux@example.com" 11 | }, 12 | "name": { 13 | "type": "string", 14 | "value": "Baz Qux" 15 | }, 16 | "url": { 17 | "type": "string", 18 | "value": "https://example.com/bazqux" 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "best-day-ever": { 3 | "type": "datetime", 4 | "value": "1987-07-05T17:45:00Z" 5 | }, 6 | "numtheory": { 7 | "boring": { 8 | "type": "bool", 9 | "value": "false" 10 | }, 11 | "perfection": [ 12 | { 13 | "type": "integer", 14 | "value": "6" 15 | }, 16 | { 17 | "type": "integer", 18 | "value": "28" 19 | }, 20 | { 21 | "type": "integer", 22 | "value": "496" 23 | } 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "empty1": {}, 3 | "empty2": {}, 4 | "empty_in_array": [ 5 | { 6 | "not_empty": { 7 | "type": "integer", 8 | "value": "1" 9 | } 10 | }, 11 | {} 12 | ], 13 | "empty_in_array2": [ 14 | {}, 15 | { 16 | "not_empty": { 17 | "type": "integer", 18 | "value": "1" 19 | } 20 | } 21 | ], 22 | "many_empty": [ 23 | {}, 24 | {}, 25 | {} 26 | ], 27 | "nested_empty": { 28 | "empty": {} 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/nested-double.json: -------------------------------------------------------------------------------- 1 | { 2 | "nest": [ 3 | [ 4 | [ 5 | { 6 | "type": "string", 7 | "value": "a" 8 | } 9 | ], 10 | [ 11 | { 12 | "type": "integer", 13 | "value": "1" 14 | }, 15 | { 16 | "type": "integer", 17 | "value": "2" 18 | }, 19 | [ 20 | { 21 | "type": "integer", 22 | "value": "3" 23 | } 24 | ] 25 | ] 26 | ] 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/multiline-quotes.toml: -------------------------------------------------------------------------------- 1 | # Make sure that quotes inside multiline strings are allowed, including right 2 | # after the opening '''/""" and before the closing '''/""" 3 | 4 | lit_one = ''''one quote'''' 5 | lit_two = '''''two quotes''''' 6 | lit_one_space = ''' 'one quote' ''' 7 | lit_two_space = ''' ''two quotes'' ''' 8 | 9 | one = """"one quote"""" 10 | two = """""two quotes""""" 11 | one_space = """ "one quote" """ 12 | two_space = """ ""two quotes"" """ 13 | 14 | mismatch1 = """aaa'''bbb""" 15 | mismatch2 = '''aaa"""bbb''' 16 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/everywhere.json: -------------------------------------------------------------------------------- 1 | { 2 | "group": { 3 | "answer": { 4 | "type": "integer", 5 | "value": "42" 6 | }, 7 | "dt": { 8 | "type": "datetime", 9 | "value": "1979-05-27T07:32:12-07:00" 10 | }, 11 | "d": { 12 | "type": "date-local", 13 | "value": "1979-05-27" 14 | }, 15 | "more": [ 16 | { 17 | "type": "integer", 18 | "value": "42" 19 | }, 20 | { 21 | "type": "integer", 22 | "value": "42" 23 | } 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/tricky.toml: -------------------------------------------------------------------------------- 1 | [section]#attached comment 2 | #[notsection] 3 | one = "11"#cmt 4 | two = "22#" 5 | three = '#' 6 | 7 | four = """# no comment 8 | # nor this 9 | #also not comment"""#is_comment 10 | 11 | five = 5.5#66 12 | six = 6#7 13 | 8 = "eight" 14 | #nine = 99 15 | ten = 10e2#1 16 | eleven = 1.11e1#23 17 | 18 | ["hash#tag"] 19 | "#!" = "hash bang" 20 | arr3 = [ "#", '#', """###""" ] 21 | arr4 = [ 1,# 9, 9, 22 | 2#,9 23 | ,#9 24 | 3#] 25 | ,4] 26 | arr5 = [[[[#["#"], 27 | ["#"]]]]#] 28 | ] 29 | tbl1 = { "#" = '}#'}#}} 30 | 31 | 32 | -------------------------------------------------------------------------------- /spec-tests/values/spec-readme-example.yaml: -------------------------------------------------------------------------------- 1 | # This is a TOML document. 2 | 3 | title: "TOML Example" 4 | 5 | owner: 6 | name: "Tom Preston-Werner" 7 | dob: 1979-05-27T07:32:00-08:00 # First class dates 8 | 9 | database: 10 | server: "192.168.1.1" 11 | ports: [ 8001, 8001, 8002 ] 12 | connection_max: 5000 13 | enabled: true 14 | 15 | servers: 16 | alpha: 17 | ip: "10.0.0.1" 18 | dc: "eqdc10" 19 | beta: 20 | ip: "10.0.0.2" 21 | dc: "eqdc10" 22 | 23 | clients: 24 | data: [ ["gamma", "delta"], [1, 2] ] 25 | hosts: [ 26 | "alpha", 27 | "omega" 28 | ] 29 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/zero.json: -------------------------------------------------------------------------------- 1 | { 2 | "zero": { 3 | "type": "float", 4 | "value": "0" 5 | }, 6 | "signed-pos": { 7 | "type": "float", 8 | "value": "0" 9 | }, 10 | "signed-neg": { 11 | "type": "float", 12 | "value": "0" 13 | }, 14 | "exponent": { 15 | "type": "float", 16 | "value": "0" 17 | }, 18 | "exponent-two-0": { 19 | "type": "float", 20 | "value": "0" 21 | }, 22 | "exponent-signed-pos": { 23 | "type": "float", 24 | "value": "0" 25 | }, 26 | "exponent-signed-neg": { 27 | "type": "float", 28 | "value": "0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/append-with-dotted-keys-1.toml: -------------------------------------------------------------------------------- 1 | # First a.b.c defines a table: a.b.c = {z=9} 2 | # 3 | # Then we define a.b.c.t = "str" to add a str to the above table, making it: 4 | # 5 | # a.b.c = {z=9, t="..."} 6 | # 7 | # While this makes sense, logically, it was decided this is not valid TOML as 8 | # it's too confusing/convoluted. 9 | # 10 | # See: https://github.com/toml-lang/toml/issues/846 11 | # https://github.com/toml-lang/toml/pull/859 12 | 13 | [a.b.c] 14 | z = 9 15 | 16 | [a] 17 | b.c.t = "Using dotted keys to add to [a.b.c] after explicitly defining it above is not allowed" 18 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/hetergeneous.json: -------------------------------------------------------------------------------- 1 | { 2 | "mixed": [ 3 | [ 4 | { 5 | "type": "integer", 6 | "value": "1" 7 | }, 8 | { 9 | "type": "integer", 10 | "value": "2" 11 | } 12 | ], 13 | [ 14 | { 15 | "type": "string", 16 | "value": "a" 17 | }, 18 | { 19 | "type": "string", 20 | "value": "b" 21 | } 22 | ], 23 | [ 24 | { 25 | "type": "float", 26 | "value": "1.1" 27 | }, 28 | { 29 | "type": "float", 30 | "value": "2.1" 31 | } 32 | ] 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/quoted-dots.json: -------------------------------------------------------------------------------- 1 | { 2 | "plain": { 3 | "type": "integer", 4 | "value": "1" 5 | }, 6 | "plain_table": { 7 | "plain": { 8 | "type": "integer", 9 | "value": "3" 10 | }, 11 | "with.dot": { 12 | "type": "integer", 13 | "value": "4" 14 | } 15 | }, 16 | "table": { 17 | "withdot": { 18 | "key.with.dots": { 19 | "type": "integer", 20 | "value": "6" 21 | }, 22 | "plain": { 23 | "type": "integer", 24 | "value": "5" 25 | } 26 | } 27 | }, 28 | "with.dot": { 29 | "type": "integer", 30 | "value": "2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/float/exponent.json: -------------------------------------------------------------------------------- 1 | { 2 | "lower": { 3 | "type": "float", 4 | "value": "300.0" 5 | }, 6 | "minustenth": { 7 | "type": "float", 8 | "value": "-0.1" 9 | }, 10 | "neg": { 11 | "type": "float", 12 | "value": "0.03" 13 | }, 14 | "pointlower": { 15 | "type": "float", 16 | "value": "310.0" 17 | }, 18 | "pointupper": { 19 | "type": "float", 20 | "value": "310.0" 21 | }, 22 | "pos": { 23 | "type": "float", 24 | "value": "300.0" 25 | }, 26 | "upper": { 27 | "type": "float", 28 | "value": "300.0" 29 | }, 30 | "zero": { 31 | "type": "float", 32 | "value": "3.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /internal/stack.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | type ArrayKeyStack struct { 8 | stack []string 9 | } 10 | 11 | func (a *ArrayKeyStack) Push(key string, v Var) (toClose []string) { 12 | 13 | for { 14 | if len(a.stack) == 0 { 15 | break 16 | } 17 | 18 | ck := a.stack[len(a.stack)-1] 19 | 20 | if strings.HasPrefix(key, ck) { 21 | break 22 | } 23 | 24 | toClose = append(toClose, ck) 25 | a.stack = a.stack[:len(a.stack)-1] 26 | } 27 | 28 | if v == ArrayVar { 29 | if len(a.stack) > 0 && a.stack[len(a.stack)-1] == key { 30 | return append(toClose, a.stack[len(a.stack)-1]) 31 | } 32 | a.stack = append(a.stack, key) 33 | } 34 | return toClose 35 | } 36 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/table/array-implicit.toml: -------------------------------------------------------------------------------- 1 | # This test is a bit tricky. It should fail because the first use of 2 | # `[[albums.songs]]` without first declaring `albums` implies that `albums` 3 | # must be a table. The alternative would be quite weird. Namely, it wouldn't 4 | # comply with the TOML spec: "Each double-bracketed sub-table will belong to 5 | # the most *recently* defined table element *above* it." 6 | # 7 | # This is in contrast to the *valid* test, table-array-implicit where 8 | # `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared 9 | # later. (Although, `[albums]` could be.) 10 | [[albums.songs]] 11 | name = "Glory Days" 12 | 13 | [[albums]] 14 | name = "Born in the USA" 15 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/dotted.toml: -------------------------------------------------------------------------------- 1 | # Note: this file contains literal tab characters. 2 | 3 | name.first = "Arthur" 4 | "name".'last' = "Dent" 5 | 6 | many.dots.here.dot.dot.dot = 42 7 | 8 | # Space are ignored, and key parts can be quoted. 9 | count.a = 1 10 | count . b = 2 11 | "count"."c" = 3 12 | "count" . "d" = 4 13 | 'count'.'e' = 5 14 | 'count' . 'f' = 6 15 | "count".'g' = 7 16 | "count" . 'h' = 8 17 | count.'i' = 9 18 | count . 'j' = 10 19 | "count".k = 11 20 | "count" . l = 12 21 | 22 | [tbl] 23 | a.b.c = 42.666 24 | 25 | [a.few.dots] 26 | polka.dot = "again?" 27 | polka.dance-with = "Dot" 28 | 29 | [[arr]] 30 | a.b.c=1 31 | a.b.d=2 32 | 33 | [[arr]] 34 | a.b.c=3 35 | a.b.d=4 36 | -------------------------------------------------------------------------------- /spec-tests/values/spec-readme-example.toml: -------------------------------------------------------------------------------- 1 | # This is a TOML document. 2 | 3 | title = "TOML Example" 4 | 5 | [owner] 6 | name = "Tom Preston-Werner" 7 | dob = 1979-05-27T07:32:00-08:00 # First class dates 8 | 9 | [database] 10 | server = "192.168.1.1" 11 | ports = [ 8001, 8001, 8002 ] 12 | connection_max = 5000 13 | enabled = true 14 | 15 | [servers] 16 | 17 | # Indentation (tabs and/or spaces) is allowed but not required 18 | [servers.alpha] 19 | ip = "10.0.0.1" 20 | dc = "eqdc10" 21 | 22 | [servers.beta] 23 | ip = "10.0.0.2" 24 | dc = "eqdc10" 25 | 26 | [clients] 27 | data = [ ["gamma", "delta"], [1, 2] ] 28 | 29 | # Line breaks are OK when inside arrays 30 | hosts = [ 31 | "alpha", 32 | "omega" 33 | ] 34 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/array.json: -------------------------------------------------------------------------------- 1 | { 2 | "people": [ 3 | { 4 | "first_name": { 5 | "type": "string", 6 | "value": "Bruce" 7 | }, 8 | "last_name": { 9 | "type": "string", 10 | "value": "Springsteen" 11 | } 12 | }, 13 | { 14 | "first_name": { 15 | "type": "string", 16 | "value": "Eric" 17 | }, 18 | "last_name": { 19 | "type": "string", 20 | "value": "Clapton" 21 | } 22 | }, 23 | { 24 | "first_name": { 25 | "type": "string", 26 | "value": "Bob" 27 | }, 28 | "last_name": { 29 | "type": "string", 30 | "value": "Seger" 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/spec-example-1.toml: -------------------------------------------------------------------------------- 1 | # This is a TOML document. Boom. 2 | 3 | title = "TOML Example" 4 | 5 | [owner] 6 | name = "Lance Uppercut" 7 | dob = 1979-05-27T07:32:00-08:00 # First class dates? Why not? 8 | 9 | [database] 10 | server = "192.168.1.1" 11 | ports = [ 8001, 8001, 8002 ] 12 | connection_max = 5000 13 | enabled = true 14 | 15 | [servers] 16 | 17 | # You can indent as you please. Tabs or spaces. TOML don't care. 18 | [servers.alpha] 19 | ip = "10.0.0.1" 20 | dc = "eqdc10" 21 | 22 | [servers.beta] 23 | ip = "10.0.0.2" 24 | dc = "eqdc10" 25 | 26 | [clients] 27 | data = [ ["gamma", "delta"], [1, 2] ] 28 | 29 | # Line breaks are OK when inside arrays 30 | hosts = [ 31 | "alpha", 32 | "omega" 33 | ] 34 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-many.json: -------------------------------------------------------------------------------- 1 | { 2 | "people": [ 3 | { 4 | "first_name": { 5 | "type": "string", 6 | "value": "Bruce" 7 | }, 8 | "last_name": { 9 | "type": "string", 10 | "value": "Springsteen" 11 | } 12 | }, 13 | { 14 | "first_name": { 15 | "type": "string", 16 | "value": "Eric" 17 | }, 18 | "last_name": { 19 | "type": "string", 20 | "value": "Clapton" 21 | } 22 | }, 23 | { 24 | "first_name": { 25 | "type": "string", 26 | "value": "Bob" 27 | }, 28 | "last_name": { 29 | "type": "string", 30 | "value": "Seger" 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/comment/everywhere.toml: -------------------------------------------------------------------------------- 1 | # Top comment. 2 | # Top comment. 3 | # Top comment. 4 | 5 | # [no-extraneous-groups-please] 6 | 7 | [group] # Comment 8 | answer = 42 # Comment 9 | # no-extraneous-keys-please = 999 10 | # Inbetween comment. 11 | more = [ # Comment 12 | # What about multiple # comments? 13 | # Can you handle it? 14 | # 15 | # Evil. 16 | # Evil. 17 | 42, 42, # Comments within arrays are fun. 18 | # What about multiple # comments? 19 | # Can you handle it? 20 | # 21 | # Evil. 22 | # Evil. 23 | # ] Did I fool you? 24 | ] # Hopefully not. 25 | 26 | # Make sure the space between the datetime and "#" isn't lexed. 27 | dt = 1979-05-27T07:32:12-07:00 # c 28 | d = 1979-05-27 # Comment 29 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/literals.json: -------------------------------------------------------------------------------- 1 | { 2 | "bin1": { 3 | "type": "integer", 4 | "value": "214" 5 | }, 6 | "bin2": { 7 | "type": "integer", 8 | "value": "5" 9 | }, 10 | "hex1": { 11 | "type": "integer", 12 | "value": "3735928559" 13 | }, 14 | "hex2": { 15 | "type": "integer", 16 | "value": "3735928559" 17 | }, 18 | "hex3": { 19 | "type": "integer", 20 | "value": "3735928559" 21 | }, 22 | "hex4": { 23 | "type": "integer", 24 | "value": "2439" 25 | }, 26 | "oct1": { 27 | "type": "integer", 28 | "value": "342391" 29 | }, 30 | "oct2": { 31 | "type": "integer", 32 | "value": "493" 33 | }, 34 | "oct3": { 35 | "type": "integer", 36 | "value": "501" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example_test.go: -------------------------------------------------------------------------------- 1 | package toml_test 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/komkom/toml" 9 | ) 10 | 11 | func ExampleReader() { 12 | 13 | doc := ` 14 | [some] 15 | toml="doc" 16 | [to.map] 17 | "!"=true` 18 | 19 | dec := json.NewDecoder(toml.New(bytes.NewBufferString(doc))) 20 | 21 | st := struct { 22 | Some struct { 23 | Toml string `json:"toml"` 24 | } `json:"some"` 25 | 26 | To struct { 27 | Map struct { 28 | IsMarked bool `json:"!"` 29 | } 30 | } `json:"to"` 31 | }{} 32 | 33 | err := dec.Decode(&st) 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | fmt.Printf("toml: %v", st.Some.Toml) 39 | fmt.Printf(" is_marked: %v", st.To.Map.IsMarked) 40 | 41 | // Output: toml: doc is_marked: true 42 | } 43 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/escape-tricky.json: -------------------------------------------------------------------------------- 1 | { 2 | "end_esc": { 3 | "type": "string", 4 | "value": "String does not end here\" but ends here\\" 5 | }, 6 | "lit_end_esc": { 7 | "type": "string", 8 | "value": "String ends here\\" 9 | }, 10 | "lit_multiline_end": { 11 | "type": "string", 12 | "value": "There is no escape\\" 13 | }, 14 | "lit_multiline_not_unicode": { 15 | "type": "string", 16 | "value": "\\u007f" 17 | }, 18 | "multiline_end_esc": { 19 | "type": "string", 20 | "value": "When will it end? \"\"\"...\"\"\" should be here\"" 21 | }, 22 | "multiline_not_unicode": { 23 | "type": "string", 24 | "value": "\\u0041" 25 | }, 26 | "multiline_unicode": { 27 | "type": "string", 28 | "value": " " 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/control/control.multi: -------------------------------------------------------------------------------- 1 | # NOTE: this file contains literal control characters. 2 | comment-null = "null" # 3 | comment-lf = "ctrl-P" #  4 | comment-us = "ctrl-_" #  5 | comment-del = "0x7f" #  6 | comment-cr = "Carriage return in comment" # a=1 7 | 8 | string-null = "null" 9 | string-lf = "null" 10 | string-us = "null" 11 | string-del = "null" 12 | 13 | rawstring-null = 'null' 14 | rawstring-lf = 'null' 15 | rawstring-us = 'null' 16 | rawstring-del = 'null' 17 | 18 | multi-null = """null""" 19 | multi-lf = """null""" 20 | multi-us = """null""" 21 | multi-del = """null""" 22 | 23 | rawmulti-null = '''null''' 24 | rawmulti-lf = '''null''' 25 | rawmulti-us = '''null''' 26 | rawmulti-del = '''null''' 27 | 28 | string-bs = "backspace" 29 | 30 | bare-null = "some value" 31 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/case-sensitive.json: -------------------------------------------------------------------------------- 1 | { 2 | "Section": { 3 | "M": { 4 | "type": "string", 5 | "value": "latin letter M" 6 | }, 7 | "name": { 8 | "type": "string", 9 | "value": "different section!!" 10 | }, 11 | "Μ": { 12 | "type": "string", 13 | "value": "greek capital letter MU" 14 | }, 15 | "μ": { 16 | "type": "string", 17 | "value": "greek small letter mu" 18 | } 19 | }, 20 | "sectioN": { 21 | "type": "string", 22 | "value": "NN" 23 | }, 24 | "section": { 25 | "NAME": { 26 | "type": "string", 27 | "value": "upper" 28 | }, 29 | "Name": { 30 | "type": "string", 31 | "value": "capitalized" 32 | }, 33 | "name": { 34 | "type": "string", 35 | "value": "lower" 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/escapes.toml: -------------------------------------------------------------------------------- 1 | backspace = "This string has a \b backspace character." 2 | tab = "This string has a \t tab character." 3 | newline = "This string has a \n new line character." 4 | formfeed = "This string has a \f form feed character." 5 | carriage = "This string has a \r carriage return character." 6 | quote = "This string has a \" quote character." 7 | backslash = "This string has a \\ backslash character." 8 | notunicode1 = "This string does not have a unicode \\u escape." 9 | notunicode2 = "This string does not have a unicode \u005Cu escape." 10 | notunicode3 = "This string does not have a unicode \\u0075 escape." 11 | notunicode4 = "This string does not have a unicode \\\u0075 escape." 12 | delete = "This string has a \u007F delete control code." 13 | unitseparator = "This string has a \u001F unit separator control code." 14 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/raw.json: -------------------------------------------------------------------------------- 1 | { 2 | "backslash": { 3 | "type": "string", 4 | "value": "This string has a \\\\ backslash character." 5 | }, 6 | "backspace": { 7 | "type": "string", 8 | "value": "This string has a \\b backspace character." 9 | }, 10 | "carriage": { 11 | "type": "string", 12 | "value": "This string has a \\r carriage return character." 13 | }, 14 | "formfeed": { 15 | "type": "string", 16 | "value": "This string has a \\f form feed character." 17 | }, 18 | "newline": { 19 | "type": "string", 20 | "value": "This string has a \\n new line character." 21 | }, 22 | "slash": { 23 | "type": "string", 24 | "value": "This string has a \\/ slash character." 25 | }, 26 | "tab": { 27 | "type": "string", 28 | "value": "This string has a \\t tab character." 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/key/alphanum.json: -------------------------------------------------------------------------------- 1 | { 2 | "000111": { 3 | "type": "string", 4 | "value": "leading" 5 | }, 6 | "10e3": { 7 | "type": "string", 8 | "value": "false float" 9 | }, 10 | "123": { 11 | "type": "string", 12 | "value": "num" 13 | }, 14 | "2018_10": { 15 | "001": { 16 | "type": "integer", 17 | "value": "1" 18 | } 19 | }, 20 | "34-11": { 21 | "type": "integer", 22 | "value": "23" 23 | }, 24 | "a-a-a": { 25 | "_": { 26 | "type": "bool", 27 | "value": "false" 28 | } 29 | }, 30 | "alpha": { 31 | "type": "string", 32 | "value": "a" 33 | }, 34 | "one1two2": { 35 | "type": "string", 36 | "value": "mixed" 37 | }, 38 | "under_score": { 39 | "type": "string", 40 | "value": "___" 41 | }, 42 | "with-dash": { 43 | "type": "string", 44 | "value": "dashed" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/float/float.multi: -------------------------------------------------------------------------------- 1 | leading-zero = 03.14 2 | leading-zero-neg = -03.14 3 | leading-zero-plus = +03.14 4 | 5 | leading-point = .12345 6 | leading-point-neg = -.12345 7 | leading-point-plus = +.12345 8 | 9 | trailing-point = 1. 10 | trailing-point-min = -1. 11 | trailing-point-plus = +1. 12 | 13 | trailing-us = 1.2_ 14 | leading-us = _1.2 15 | us-before-point = 1_.2 16 | us-after-point = 1._2 17 | 18 | double-point-1 = 0..1 19 | double-point-2 = 0.1.2 20 | 21 | exp-point-1 = 1e2.3 22 | exp-point-2 = 1.e2 23 | 24 | exp-double-e-1 = 1ee2 25 | exp-double-e-2 = 1e2e3 26 | 27 | exp-leading-us = 1e_23 28 | exp-trailing-us = 1e_23_ 29 | exp-double-us = 1e__23 30 | 31 | inf-incomplete-1 = in 32 | inf-incomplete-2 = +in 33 | inf-incomplete-3 = -in 34 | 35 | nan-incomplete-1 = na 36 | nan-incomplete-2 = +na 37 | nan-incomplete-3 = -na 38 | 39 | nan_underscore = na_n 40 | inf_underscore = in_f 41 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/inline-table.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": { 3 | "first": { 4 | "type": "string", 5 | "value": "Tom" 6 | }, 7 | "last": { 8 | "type": "string", 9 | "value": "Preston-Werner" 10 | } 11 | }, 12 | "point": { 13 | "x": { 14 | "type": "integer", 15 | "value": "1" 16 | }, 17 | "y": { 18 | "type": "integer", 19 | "value": "2" 20 | } 21 | }, 22 | "simple": { 23 | "a": { 24 | "type": "integer", 25 | "value": "1" 26 | } 27 | }, 28 | "str-key": { 29 | "a": { 30 | "type": "integer", 31 | "value": "1" 32 | } 33 | }, 34 | "table-array": [ 35 | { 36 | "a": { 37 | "type": "integer", 38 | "value": "1" 39 | } 40 | }, 41 | { 42 | "b": { 43 | "type": "integer", 44 | "value": "2" 45 | } 46 | } 47 | ] 48 | } 49 | -------------------------------------------------------------------------------- /spec-tests/tests/invalid/integer/integer.multi: -------------------------------------------------------------------------------- 1 | leading-zero-1 = 01 2 | leading-zero-2 = 00 3 | leading-zero-3 = 0_0 4 | leading-zero-sign-1 = -01 5 | leading-zero-sign-2 = +01 6 | leading-zero-sign-3 = +0_1 7 | 8 | double-sign-plus = ++99 9 | double-sign-nex = --99 10 | 11 | negative-hex = -0xff 12 | negative-bin = -0b11010110 13 | negative-oct = -0o99 14 | 15 | positive-hex = +0xff 16 | positive-bin = +0b11010110 17 | positive-oct = +0o99 18 | 19 | trailing-us = 123_ 20 | leading-us = _123 21 | double-us = 1__23 22 | 23 | us-after-hex = 0x_1 24 | us-after-oct = 0o_1 25 | us-after-bin = 0b_1 26 | 27 | trailing-us-hex = 0x1_ 28 | trailing-us-oct = 0o1_ 29 | trailing-us-bin = 0b1_ 30 | 31 | leading-us-hex = _0o1 32 | leading-us-oct = _0o1 33 | leading-us-bin = _0o1 34 | 35 | invalid-hex = 0xaafz 36 | invalid-oct = 0o778 37 | invalid-bin = 0b0012 38 | 39 | capital-hex = 0X1 40 | capital-oct = 0O0 41 | capital-bin = 0B0 42 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/integer/zero.json: -------------------------------------------------------------------------------- 1 | { 2 | "a2": { 3 | "type": "integer", 4 | "value": "0" 5 | }, 6 | "a3": { 7 | "type": "integer", 8 | "value": "0" 9 | }, 10 | "b1": { 11 | "type": "integer", 12 | "value": "0" 13 | }, 14 | "b2": { 15 | "type": "integer", 16 | "value": "0" 17 | }, 18 | "b3": { 19 | "type": "integer", 20 | "value": "0" 21 | }, 22 | "d1": { 23 | "type": "integer", 24 | "value": "0" 25 | }, 26 | "d2": { 27 | "type": "integer", 28 | "value": "0" 29 | }, 30 | "d3": { 31 | "type": "integer", 32 | "value": "0" 33 | }, 34 | "h1": { 35 | "type": "integer", 36 | "value": "0" 37 | }, 38 | "h2": { 39 | "type": "integer", 40 | "value": "0" 41 | }, 42 | "h3": { 43 | "type": "integer", 44 | "value": "0" 45 | }, 46 | "o1": { 47 | "type": "integer", 48 | "value": "0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/multiline-quotes.json: -------------------------------------------------------------------------------- 1 | { 2 | "lit_one": { 3 | "type": "string", 4 | "value": "'one quote'" 5 | }, 6 | "lit_one_space": { 7 | "type": "string", 8 | "value": " 'one quote' " 9 | }, 10 | "lit_two": { 11 | "type": "string", 12 | "value": "''two quotes''" 13 | }, 14 | "lit_two_space": { 15 | "type": "string", 16 | "value": " ''two quotes'' " 17 | }, 18 | "mismatch1": { 19 | "type": "string", 20 | "value": "aaa'''bbb" 21 | }, 22 | "mismatch2": { 23 | "type": "string", 24 | "value": "aaa\"\"\"bbb" 25 | }, 26 | "one": { 27 | "type": "string", 28 | "value": "\"one quote\"" 29 | }, 30 | "one_space": { 31 | "type": "string", 32 | "value": " \"one quote\" " 33 | }, 34 | "two": { 35 | "type": "string", 36 | "value": "\"\"two quotes\"\"" 37 | }, 38 | "two_space": { 39 | "type": "string", 40 | "value": " \"\"two quotes\"\" " 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/table/array-nest.json: -------------------------------------------------------------------------------- 1 | { 2 | "albums": [ 3 | { 4 | "name": { 5 | "type": "string", 6 | "value": "Born to Run" 7 | }, 8 | "songs": [ 9 | { 10 | "name": { 11 | "type": "string", 12 | "value": "Jungleland" 13 | } 14 | }, 15 | { 16 | "name": { 17 | "type": "string", 18 | "value": "Meeting Across the River" 19 | } 20 | } 21 | ] 22 | }, 23 | { 24 | "name": { 25 | "type": "string", 26 | "value": "Born in the USA" 27 | }, 28 | "songs": [ 29 | { 30 | "name": { 31 | "type": "string", 32 | "value": "Glory Days" 33 | } 34 | }, 35 | { 36 | "name": { 37 | "type": "string", 38 | "value": "Dancing in the Dark" 39 | } 40 | } 41 | ] 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /internal/map_test.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestMap(t *testing.T) { 10 | 11 | m := Map{m: make(map[string]Map)} 12 | 13 | key := []string{`1`, `2`, `3`} 14 | 15 | ok := m.Set(key, nil, BasicVar) 16 | assert.True(t, ok) 17 | 18 | r, ok := m.Get(key) 19 | assert.True(t, ok) 20 | 21 | assert.Equal(t, BasicVar, r.Var) 22 | assert.Nil(t, r.m) 23 | 24 | ok = m.Set(key[:2], nil, BasicVar) 25 | assert.False(t, ok) 26 | 27 | ok = m.Clear(key[:2]) 28 | assert.True(t, ok) 29 | 30 | _, ok = m.Get(key) 31 | assert.False(t, ok) 32 | 33 | ok = m.Set(key, nil, BasicVar) 34 | assert.True(t, ok) 35 | 36 | _, ok = m.Get(key) 37 | assert.True(t, ok) 38 | 39 | ok = m.Set([]string{`a`, `b`}, nil, TableVar) 40 | assert.True(t, ok) 41 | 42 | ok = m.Set([]string{`a`, `b`, `c`}, []string{`a`, `b`}, BasicVar) 43 | assert.True(t, ok) 44 | 45 | ok = m.Set([]string{`a`, `b`, `c`, `x`}, []string{`a`, `b`, `c`}, BasicVar) 46 | assert.False(t, ok) 47 | } 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 komika 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/inline-table/nest.json: -------------------------------------------------------------------------------- 1 | { 2 | "arr_arr_tbl_empty": [ 3 | [ 4 | {} 5 | ] 6 | ], 7 | "arr_arr_tbl_val": [ 8 | [ 9 | { 10 | "one": { 11 | "type": "integer", 12 | "value": "1" 13 | } 14 | } 15 | ] 16 | ], 17 | "arr_arr_tbls": [ 18 | [ 19 | { 20 | "one": { 21 | "type": "integer", 22 | "value": "1" 23 | } 24 | }, 25 | { 26 | "two": { 27 | "type": "integer", 28 | "value": "2" 29 | } 30 | } 31 | ] 32 | ], 33 | "arr_tbl_tbl": [ 34 | { 35 | "tbl": { 36 | "one": { 37 | "type": "integer", 38 | "value": "1" 39 | } 40 | } 41 | } 42 | ], 43 | "tbl_arr_tbl": { 44 | "arr_tbl": [ 45 | { 46 | "one": { 47 | "type": "integer", 48 | "value": "1" 49 | } 50 | } 51 | ] 52 | }, 53 | "tbl_tbl_empty": { 54 | "tbl_0": {} 55 | }, 56 | "tbl_tbl_val": { 57 | "tbl_1": { 58 | "one": { 59 | "type": "integer", 60 | "value": "1" 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /internal/defs.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | type Var string 8 | 9 | var ( 10 | NodefVar Var = `nodef-var` 11 | BasicVar Var = `basic-var` 12 | TableVar Var = `table-var` 13 | ImplicitTableVar Var = `implicit-table-var` 14 | ArrayVar Var = `array-var` 15 | ) 16 | 17 | type DefineFunc func(key []string, v Var) bool 18 | 19 | type Defs struct { 20 | m Map 21 | arrayKeyStack *ArrayKeyStack 22 | keyFilter *KeyFilter 23 | } 24 | 25 | func MakeDefs() Defs { 26 | return Defs{m: Map{m: make(map[string]Map)}, 27 | arrayKeyStack: &ArrayKeyStack{}, 28 | keyFilter: &KeyFilter{}, 29 | } 30 | } 31 | 32 | func (d Defs) Define(key []string, insertTable []string, v Var) bool { 33 | 34 | if len(key) == 0 { 35 | return false 36 | } 37 | 38 | ok := d.m.Set(key, insertTable, v) 39 | if !ok { 40 | return false 41 | } 42 | 43 | fullKey := strings.Join(key, "\n") 44 | 45 | toClose := d.arrayKeyStack.Push(fullKey, v) 46 | for _, k := range toClose { 47 | 48 | key := strings.Split(k, "\n") 49 | ok = d.m.Clear(key) 50 | if !ok { 51 | return false 52 | } 53 | } 54 | 55 | return true 56 | } 57 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/multiline.toml: -------------------------------------------------------------------------------- 1 | # NOTE: this file includes some literal tab characters. 2 | 3 | multiline_empty_one = """""" 4 | 5 | # A newline immediately following the opening delimiter will be trimmed. 6 | multiline_empty_two = """ 7 | """ 8 | 9 | # \ at the end of line trims newlines as well; note that last \ is followed by 10 | # two spaces, which are ignored. 11 | multiline_empty_three = """\ 12 | """ 13 | multiline_empty_four = """\ 14 | \ 15 | \ 16 | """ 17 | 18 | equivalent_one = "The quick brown fox jumps over the lazy dog." 19 | equivalent_two = """ 20 | The quick brown \ 21 | 22 | 23 | fox jumps over \ 24 | the lazy dog.""" 25 | 26 | equivalent_three = """\ 27 | The quick brown \ 28 | fox jumps over \ 29 | the lazy dog.\ 30 | """ 31 | 32 | whitespace-after-bs = """\ 33 | The quick brown \ 34 | fox jumps over \ 35 | the lazy dog.\ 36 | """ 37 | 38 | no-space = """a\ 39 | b""" 40 | 41 | # Has tab character. 42 | keep-ws-before = """a \ 43 | b""" 44 | 45 | escape-bs-1 = """a \\ 46 | b""" 47 | 48 | escape-bs-2 = """a \\\ 49 | b""" 50 | 51 | escape-bs-3 = """a \\\\ 52 | b""" 53 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 2 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 4 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 5 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 6 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 7 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 8 | github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= 9 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 10 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 11 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 12 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 13 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 14 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/array/array.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": [ 3 | { 4 | "type": "integer", 5 | "value": "1" 6 | }, 7 | { 8 | "type": "integer", 9 | "value": "2" 10 | } 11 | ], 12 | "dates": [ 13 | { 14 | "type": "datetime", 15 | "value": "1987-07-05T17:45:00Z" 16 | }, 17 | { 18 | "type": "datetime", 19 | "value": "1979-05-27T07:32:00Z" 20 | }, 21 | { 22 | "type": "datetime", 23 | "value": "2006-06-01T11:00:00Z" 24 | } 25 | ], 26 | "floats": [ 27 | { 28 | "type": "float", 29 | "value": "1.1" 30 | }, 31 | { 32 | "type": "float", 33 | "value": "2.1" 34 | }, 35 | { 36 | "type": "float", 37 | "value": "3.1" 38 | } 39 | ], 40 | "ints": [ 41 | { 42 | "type": "integer", 43 | "value": "1" 44 | }, 45 | { 46 | "type": "integer", 47 | "value": "2" 48 | }, 49 | { 50 | "type": "integer", 51 | "value": "3" 52 | } 53 | ], 54 | "strings": [ 55 | { 56 | "type": "string", 57 | "value": "a" 58 | }, 59 | { 60 | "type": "string", 61 | "value": "b" 62 | }, 63 | { 64 | "type": "string", 65 | "value": "c" 66 | } 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/multiline.json: -------------------------------------------------------------------------------- 1 | { 2 | "equivalent_one": { 3 | "type": "string", 4 | "value": "The quick brown fox jumps over the lazy dog." 5 | }, 6 | "equivalent_three": { 7 | "type": "string", 8 | "value": "The quick brown fox jumps over the lazy dog." 9 | }, 10 | "equivalent_two": { 11 | "type": "string", 12 | "value": "The quick brown fox jumps over the lazy dog." 13 | }, 14 | "escape-bs-1": { 15 | "type": "string", 16 | "value": "a \\\nb" 17 | }, 18 | "escape-bs-2": { 19 | "type": "string", 20 | "value": "a \\b" 21 | }, 22 | "escape-bs-3": { 23 | "type": "string", 24 | "value": "a \\\\\n b" 25 | }, 26 | "keep-ws-before": { 27 | "type": "string", 28 | "value": "a \tb" 29 | }, 30 | "multiline_empty_four": { 31 | "type": "string", 32 | "value": "" 33 | }, 34 | "multiline_empty_one": { 35 | "type": "string", 36 | "value": "" 37 | }, 38 | "multiline_empty_three": { 39 | "type": "string", 40 | "value": "" 41 | }, 42 | "multiline_empty_two": { 43 | "type": "string", 44 | "value": "" 45 | }, 46 | "no-space": { 47 | "type": "string", 48 | "value": "ab" 49 | }, 50 | "whitespace-after-bs": { 51 | "type": "string", 52 | "value": "The quick brown fox jumps over the lazy dog." 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /internal/convert_test.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestConvert(t *testing.T) { 11 | 12 | tests := []struct { 13 | value string 14 | expected int64 15 | }{ 16 | { 17 | value: `0x12AFE`, 18 | expected: 76542, 19 | }, 20 | { 21 | value: `0x00012AFE`, 22 | expected: 76542, 23 | }, 24 | { 25 | value: `0o67`, 26 | expected: 55, 27 | }, 28 | { 29 | value: `0o25677`, 30 | expected: 11199, 31 | }, 32 | { 33 | value: `0b11`, 34 | expected: 3, 35 | }, 36 | { 37 | value: `0b101`, 38 | expected: 5, 39 | }, 40 | { 41 | value: `0b0011`, 42 | expected: 3, 43 | }, 44 | } 45 | 46 | var err error 47 | for _, ts := range tests { 48 | 49 | var total int64 50 | 51 | for _, r := range ts.value[2:] { 52 | if ts.value[:2] == `0x` { 53 | total, err = addNumber(r, total, HexNumberType) 54 | require.NoError(t, err) 55 | } 56 | if ts.value[:2] == `0o` { 57 | total, err = addNumber(r, total, OctalNumberType) 58 | require.NoError(t, err) 59 | } 60 | if ts.value[:2] == `0b` { 61 | total, err = addNumber(r, total, BinNumberType) 62 | require.NoError(t, err) 63 | } 64 | } 65 | assert.Equal(t, ts.expected, total) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /internal/encoder_test.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "testing" 7 | ) 8 | 9 | type path struct { 10 | segs []string 11 | v Var 12 | } 13 | 14 | func TestKeyFilter(t *testing.T) { 15 | 16 | tests := []struct { 17 | paths []path 18 | }{ 19 | { 20 | paths: []path{ 21 | 22 | {segs: []string{`a`, `b`}, v: TableVar}, 23 | {segs: []string{`a`, `b`, `c`}, v: ArrayVar}, 24 | 25 | {segs: []string{`a`, `b`, `c`}, v: ArrayVar}, 26 | 27 | {segs: []string{`a`, `b`, `c`, `d`}, v: ArrayVar}, 28 | }, 29 | }, 30 | 31 | /* 32 | { 33 | paths: []path{ 34 | 35 | {segs: []string{`a`, `b`}, v: TableVar}, 36 | {segs: []string{`a`, `b`, `c`}, v: TableVar}, 37 | 38 | {segs: []string{`a`, `b`}, v: TableVar}, 39 | 40 | {segs: []string{`a`, `b`, `d`}, v: TableVar}, 41 | 42 | {segs: []string{`x`}, v: TableVar}, 43 | 44 | {segs: []string{`y`}, v: TableVar}, 45 | 46 | {segs: []string{`x`, `y`}, v: TableVar}, 47 | 48 | {segs: []string{``}, v: TableVar}, 49 | }, 50 | }, 51 | */ 52 | } 53 | 54 | for _, ts := range tests { 55 | 56 | buf := &bytes.Buffer{} 57 | fi := &KeyFilter{} 58 | 59 | for idx, p := range ts.paths { 60 | fi.Push(p.segs, p.v, buf) 61 | 62 | fmt.Printf("_line%v %s\n", idx, buf.Bytes()) 63 | } 64 | 65 | fmt.Printf("___ %s\n", buf.Bytes()) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Go Report Card](https://goreportcard.com/badge/github.com/komkom/toml)](https://goreportcard.com/report/github.com/komkom/toml) 2 | [![GoDoc](https://godoc.org/github.com/komkom/toml?status.svg)](https://godoc.org/github.com/komkom/toml) 3 | 4 | # TOML 5 | A TOML parser and JSON encoder. 6 | 7 | [TOML 1.0 compliant](https://toml.io/en/v1.0.0) 8 | 9 | [give it a try](https://komkom.github.io/toml/) 10 | 11 | Installation: 12 | 13 | ``` 14 | go get github.com/komkom/toml 15 | ``` 16 | 17 | # Unmarshaling a toml doc 18 | 19 | Since the parser transforms a toml in stream into a valid json, normal json unmarshaling from the std lib can be used. 20 | 21 | ``` 22 | doc := ` 23 | [some] 24 | toml="doc"` 25 | 26 | dec := json.NewDecoder(toml.New(bytes.NewBufferString(doc))) 27 | 28 | st := struct { 29 | Some struct { 30 | Toml string `json:"toml"` 31 | } `json:"some"` 32 | }{} 33 | 34 | err := dec.Decode(&st) 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | fmt.Printf("toml: %v\n", st.Some.Toml) 40 | ``` 41 | 42 | # Performance Considerations 43 | 44 | In the repo there are two benchmarks comparing throughputs of just reading data from memory versus also transforming and parsing the data. The parser slows down data throughput around 15x here. 45 | These benchmarks are by no means thorough and only hints at an estimate. 46 | 47 | ``` 48 | Parser Throughput 7.05 MB/s 49 | Memory Throughput 100.03 MB/s 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /reader.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | toml "github.com/komkom/toml/internal" 8 | "github.com/pkg/errors" 9 | ) 10 | 11 | type Reader struct { 12 | filter *toml.Filter 13 | filterDone bool 14 | reader io.Reader 15 | readerDone bool 16 | } 17 | 18 | // New wraps an io.Reader around an io.Reader. 19 | // Reading data from this Reader reads data from 20 | // its underlying wrapped io.Reader, parses and 21 | // encodes it as a JSON stream. 22 | func New(reader io.Reader) *Reader { 23 | return &Reader{ 24 | filter: toml.NewFilter(), 25 | reader: reader, 26 | } 27 | } 28 | 29 | func (r *Reader) Read(p []byte) (int, error) { 30 | 31 | if !r.readerDone { 32 | for r.filter.State.Buf.Len() < len(p) { 33 | n, err := r.reader.Read(p) 34 | _, err = r.filter.Write(p[:n]) 35 | if err != nil { 36 | return 0, err 37 | } 38 | 39 | if errors.Is(err, io.EOF) || n == 0 { 40 | r.readerDone = true 41 | break 42 | } 43 | 44 | if err != nil { 45 | return 0, err 46 | } 47 | } 48 | } 49 | 50 | if r.readerDone && !r.filterDone { 51 | r.filterDone = true 52 | r.filter.WriteRune('\n') 53 | r.filter.WriteRune(toml.EOF) 54 | r.filter.Close() 55 | } 56 | 57 | if r.readerDone && len(r.filter.State.Buf.Bytes()) == 0 { 58 | if len(r.filter.State.Scopes) != 0 { 59 | return 0, fmt.Errorf(`invalid EOF`) 60 | } 61 | return 0, io.EOF 62 | } 63 | 64 | n, err := r.filter.State.Buf.Read(p) 65 | r.filter.State.Buf.Truncate(len(r.filter.State.Buf.Bytes())) 66 | return n, err 67 | } 68 | -------------------------------------------------------------------------------- /spec-tests/tests/valid/string/escapes.json: -------------------------------------------------------------------------------- 1 | { 2 | "backslash": { 3 | "type": "string", 4 | "value": "This string has a \\ backslash character." 5 | }, 6 | "backspace": { 7 | "type": "string", 8 | "value": "This string has a \u0008 backspace character." 9 | }, 10 | "carriage": { 11 | "type": "string", 12 | "value": "This string has a \r carriage return character." 13 | }, 14 | "delete": { 15 | "type": "string", 16 | "value": "This string has a  delete control code." 17 | }, 18 | "formfeed": { 19 | "type": "string", 20 | "value": "This string has a \u000c form feed character." 21 | }, 22 | "newline": { 23 | "type": "string", 24 | "value": "This string has a \n new line character." 25 | }, 26 | "notunicode1": { 27 | "type": "string", 28 | "value": "This string does not have a unicode \\u escape." 29 | }, 30 | "notunicode2": { 31 | "type": "string", 32 | "value": "This string does not have a unicode \\u escape." 33 | }, 34 | "notunicode3": { 35 | "type": "string", 36 | "value": "This string does not have a unicode \\u0075 escape." 37 | }, 38 | "notunicode4": { 39 | "type": "string", 40 | "value": "This string does not have a unicode \\u escape." 41 | }, 42 | "quote": { 43 | "type": "string", 44 | "value": "This string has a \" quote character." 45 | }, 46 | "tab": { 47 | "type": "string", 48 | "value": "This string has a \t tab character." 49 | }, 50 | "unitseparator": { 51 | "type": "string", 52 | "value": "This string has a \u001f unit separator control code." 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /internal/convert.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "fmt" 5 | "unicode" 6 | 7 | "github.com/pkg/errors" 8 | ) 9 | 10 | type from func(rune) (int, error) 11 | 12 | func fromHex(r rune) (int, error) { 13 | 14 | if unicode.IsOneOf([]*unicode.RangeTable{digits}, r) { 15 | 16 | return int(r) - 48, nil 17 | } 18 | 19 | if unicode.IsOneOf([]*unicode.RangeTable{hex}, r) { 20 | 21 | v := int(r) 22 | 23 | if v > 70 { 24 | return v - 97 + 10, nil 25 | } 26 | 27 | return v - 65 + 10, nil 28 | } 29 | 30 | return 0, fmt.Errorf("not a valid hex value") 31 | } 32 | 33 | func fromOctal(r rune) (int, error) { 34 | 35 | v := int(r) 36 | 37 | if v >= 48 || v <= 55 { 38 | return v - 48, nil 39 | } 40 | return 0, fmt.Errorf(`not valid octal value`) 41 | } 42 | 43 | func fromBin(r rune) (int, error) { 44 | 45 | if r == '1' { 46 | return 1, nil 47 | } 48 | 49 | if r == '0' { 50 | return 0, nil 51 | } 52 | 53 | return 0, fmt.Errorf(`not valid bin value`) 54 | } 55 | 56 | func addNumber(r rune, total int64, t NumberType) (int64, error) { 57 | 58 | switch t { 59 | case BinNumberType: 60 | return add(r, total, fromBin, 2) 61 | case OctalNumberType: 62 | return add(r, total, fromOctal, 8) 63 | case HexNumberType: 64 | return add(r, total, fromHex, 16) 65 | } 66 | 67 | return 0, fmt.Errorf(`addRune type not supported`) 68 | } 69 | 70 | func add(r rune, total int64, f from, base int) (int64, error) { 71 | 72 | v, err := f(r) 73 | if err != nil { 74 | return 0, errors.Wrap(err, `add failed`) 75 | } 76 | 77 | if v == 0 && total == 0 { 78 | return 0, nil 79 | } 80 | 81 | total *= int64(base) 82 | total += int64(v) 83 | return total, nil 84 | } 85 | --------------------------------------------------------------------------------