Cameron Moore
a7b50eb8f1
Tidy ( #511 )
...
* Disconnect package godoc comment from imported file
* Add missing newline in toml.abnf
* Tag testing helper funcs
2021-04-15 16:49:19 -04:00
Cameron Moore
7d8ea80dc3
Fix scanning of float with leading zero ( #486 )
2021-03-29 20:07:26 -04:00
Thomas Pelletier
390927a0cd
Reuse AST storage between top-level expressions
...
```
Comparing:
old: v2-wip/1da2fc7 (2021-03-25 20:38:05 -0400 -0400)
run: v2-wip/3f23ab9 (2021-03-25 22:35:06 -0400 -0400)
-----------------------------------------------------------
name old time/op new time/op delta
UnmarshalSimple/v2-8 700ns ± 3% 705ns ± 2% ~ (p=0.690 n=5+5)
UnmarshalSimple/v1-8 3.85µs ± 1% 4.02µs ± 4% +4.19% (p=0.032 n=5+5)
UnmarshalSimple/bs-8 2.34µs ± 2% 2.38µs ± 3% ~ (p=0.310 n=5+5)
ReferenceFile/v2-8 32.2µs ±13% 23.9µs ± 1% -25.79% (p=0.008 n=5+5)
ReferenceFile/v1-8 270µs ± 2% 264µs ± 2% ~ (p=0.095 n=5+5)
ReferenceFile/bs-8 291µs ± 0% 294µs ± 0% +0.88% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
ReferenceFile/v2-8 37.1kB ± 0% 6.7kB ± 0% -81.91% (p=0.008 n=5+5)
ReferenceFile/v1-8 131kB ± 0% 131kB ± 0% ~ (p=0.444 n=5+5)
ReferenceFile/bs-8 80.8kB ± 0% 80.8kB ± 0% ~ (p=0.571 n=5+5)
name old allocs/op new allocs/op delta
ReferenceFile/v2-8 152 ± 0% 148 ± 0% -2.63% (p=0.008 n=5+5)
ReferenceFile/v1-8 2.65k ± 0% 2.65k ± 0% ~ (all equal)
ReferenceFile/bs-8 1.73k ± 0% 1.73k ± 0% ~ (all equal)
~/s/g/p/g/benchmark$ go test -bench=.
goos: linux
goarch: amd64
pkg: github.com/pelletier/go-toml/v2/benchmark
cpu: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
BenchmarkUnmarshalSimple/v2-8 1692444 710.7 ns/op
BenchmarkUnmarshalSimple/v1-8 307609 3862 ns/op
BenchmarkUnmarshalSimple/bs-8 520429 2285 ns/op
BenchmarkReferenceFile/v2-8 50395 24006 ns/op 6704 B/op 148 allocs/op
BenchmarkReferenceFile/v1-8 4144 264655 ns/op 130567 B/op 2649 allocs/op
BenchmarkReferenceFile/bs-8 3969 293635 ns/op 80784 B/op 1729 allocs/op
PASS
ok github.com/pelletier/go-toml/v2/benchmark 8.143s
```
2021-03-25 22:37:16 -04:00
Thomas Pelletier
1bae751a45
Linear array storage for AST
2021-03-25 19:56:02 -04:00
Thomas Pelletier
00b2f776a9
Replace branch with AST version
2021-03-15 08:46:35 -04:00
Thomas Pelletier
b4bb91fc13
test
2021-01-30 09:07:55 -05:00
Thomas Pelletier
5c66c78bc5
Remove date regexp ( #447 )
...
* Remove date regexp
Hand-roll the date matching logic to avoid trying to match a regexp on
every integer.
```
benchmark old ns/op new ns/op delta
BenchmarkUnmarshalToml-8 293449 272134 -7.26%
benchmark old allocs new allocs delta
BenchmarkUnmarshalToml-8 2746 2650 -3.50%
benchmark old bytes new bytes delta
BenchmarkUnmarshalToml-8 133604 127548 -4.53%
```
* Remove fuzzit
The company has been acquired by GitLab and shutting down.
2020-10-11 15:31:33 -04:00
x-hgg-x
96ff402934
Fix marshaling nested arrays of tables ( #395 )
...
Fixes #369
2020-05-07 08:09:23 -04:00
x-hgg-x
249d0eaf46
Restore test for accidental whitespaces ( #403 )
2020-05-06 23:15:34 -04:00
Allen
c5fbd3eba6
Add support of mixed-type array ( #376 )
...
Fixes #357
2020-05-06 23:07:57 -04:00
x-hgg-x
f1ba6388fb
Fix inline table loading errors ( #381 )
...
Fixes #379 #380
2020-05-04 13:13:55 -04:00
Allen
d05497900e
Forbid adding keys to exist inline table ( #378 )
2020-05-04 13:06:37 -04:00
Allen
947ab3f90a
add test for trailing comma in inline table ( #366 )
...
Fixes #359
2020-04-24 21:43:46 -04:00
Riya John
24d4446802
Add float to test case to check leading zeroes in exponent parts ( #363 )
...
* add float to test case to check leading zeroes in exponent parts
* add testcase for query pkg
2020-04-21 22:45:49 -04:00
Allen
a12e102214
Fix multiline + non-primitive commenting ( #336 )
...
Fixes #216
2020-03-16 22:51:47 -04:00
Allen
3503483c73
Fix unexpected token type in inline table ( #334 )
...
Fixes #321
2020-03-10 13:39:48 -04:00
Thomas Pelletier
a89a075e1b
Test for accidental newlines ( #319 )
2019-10-25 14:44:53 -04:00
Thomas Pelletier
8a362ad712
Short-date support ( #298 )
2019-10-25 13:21:44 -04:00
Jonathan Lloyd
bef0f57967
Fix key parsing in line tables ( #311 )
...
A bug was reported that indicated that inline tables did not fully support bare keys:
$ echo 'foo = { -bar => "buz"}' | ./tomljson
(1, 9): unexpected token type in inline table: Error
$ echo 'foo = { "whatever" = "buz"}' | ./tomljson
(1, 10): unexpected token type in inline table: String
echo 'foo = { _no = "buz"}' | ./tomljson
(1, 9): unexpected token type in inline table: Error
This change makes a couple of tweaks to to allow for all key variants in inline tables
Fixes : #282
2019-10-20 20:36:14 -04:00
Marcin Białoń
095a905e04
Allow space to separate date and time ( #300 )
...
Fixes #231
2019-09-19 10:45:53 -07:00
Thomas Pelletier
e1803f96f6
Support dotted-keys ( #260 )
...
Implement dotted keys as sequence of bare and quoted keys. Introduced in
TOML 0.5.0.
Fixes #230
2019-03-04 22:35:03 -08:00
xiehuc
78b76feda6
Fix integer keys in inline tables ( #239 )
...
Fixes #224
2018-09-22 11:02:51 -07:00
Thomas Pelletier
acdc450948
Fix backward incompatibility for Set* methods ( #213 )
...
Patch #185 introduced a backward incompatibility by changing the arguments
of the `Set*` methods on `Tree`.
This change restores the arguments to what they previous were, and
introduces `SetWithComment` and `SetPathWithComment` to perform the same
action.
2018-01-18 14:54:55 -08:00
Jelte Fennema
778c285afa
Add support for special float values (inf and nan) ( #210 )
2018-01-18 14:10:55 -08:00
Kazuyoshi Kato
4874e8477b
Fix parsing of single quoted keys ( #201 )
...
Patch #193 doesn't work correctly because that must be handled by the
lexer, and `parseKey()` must not handle escape sequences.
Ref #61
2018-01-18 13:52:12 -08:00
Thomas Pelletier
861c4734ac
Support for hex, oct, and bin integers ( #205 )
...
Add support for non-decimal integers. At the time of writing, this is an
unreleased backward-compatible feature of TOML:
```
Non-negative integer values may also be expressed in hexadecimal, octal, or
binary. In these formats, leading zeros are allowed (after the prefix). Hex
values are case insensitive. Underscores are allowed between digits (but
not between the prefix and the value).
# hexadecimal with prefix `0x`
hex1 = 0xDEADBEEF
hex2 = 0xdeadbeef
hex3 = 0xdead_beef
# octal with prefix `0o`
oct1 = 0o01234567
oct2 = 0o755 # useful for Unix file permissions
# binary with prefix `0b`
bin1 = 0b11010110
```
Fixes #204
2017-12-22 12:24:26 +01:00
Thomas Pelletier
b8b5e76965
Add Encoder opt to emit arrays on multiple lines ( #203 )
...
A new Encoder option emits arrays with more than one line on multiple lines.
This is off by default and toggled with `ArraysWithOneElementPerLine`.
For example:
```
A = [1,2,3]
```
Becomes:
```
A = [
1,
2,
3
]
```
Fixes #200
2017-12-18 14:57:16 +01:00
Yvonnick Esnault
690dbc9ee7
Comment annotation for Marshal ( #185 )
2017-10-01 15:05:24 -07:00
Thomas Pelletier
685a1f1cb7
Rename TomlTree to Tree ( #159 )
...
Avoid stutter.
Fixes #55
2017-05-10 17:53:23 -07:00
tro3
25e50242f6
Fix TestMissingFile on Windows ( #148 )
...
Closing #147
2017-03-21 15:10:48 +01:00
Thomas Pelletier
fee7787d3f
Rework tree from map ( #139 )
...
* Make TreeFromMap reflect to construct tree
* Fix wording of invalid value type in writeTo
Fixes #138 , #139 , #134
⚠️ TreeFromMap signature changed to `TreeFromMap(map[string]interface{}) (*TomlTree, error)`
2017-03-14 13:16:40 -07:00
Thomas Pelletier
7e6e4b1314
Rewrite TomlTree encoding ( #133 )
...
* Rewrite `TomlTree` encoding
* Introduce `TomlTree.WriteTo`
2017-03-02 09:17:06 -08:00
Thomas Pelletier
a1f048ba24
Make ToString() return an error instead of panic ( #117 )
...
Fixes #100
2017-01-15 18:49:11 -08:00
Thomas Pelletier
439fbba1f8
Make lexComment jump back to the previous state ( #122 )
...
When a comment appears in an rvalue, the lexer needs to jump back to
lexRValue, not to lexVoid.
Fixes #120 .
2016-12-29 19:51:04 +01:00
Christopher Mancini
017119f7a7
Use a single line for slice encoding ( #119 )
2016-12-13 15:20:06 +01:00
Thomas Pelletier
ce7be745f0
Rename group to table ( #115 )
...
* Rename Group to Table Fixes #45
* Change fmt.Errorf to errors.new for simple strings
2016-12-03 12:32:16 +01:00
Cameron Moore
45932ad32d
Handle nil, map[string]string, and map[interface{}]interface{} input ( #103 )
...
* Handle map[string]string and map[interface{}]interface{} input
* Handle nil values
Fixes #99
2016-09-20 09:07:15 +02:00
Cameron Moore
67b7b944a8
Support all numeric type conversions ( #102 )
...
Fixes #101
2016-09-20 09:04:39 +02:00
Thomas Pelletier
31055c2ff0
Allow empty quoted keys ( #97 )
2016-09-06 22:25:57 +02:00
Cameron Moore
0599275eb9
Simplify redundant types in literals ( #95 )
...
Using `gofmt -s`
2016-08-23 09:45:54 +02:00
Thomas Pelletier
64ff1ea4d5
Don't hang when reading an invalid rvalue ( #77 )
...
Fixes #76
2016-06-30 16:21:25 +02:00
Thomas Pelletier
8d9c606c69
Improve test coverage ( #66 )
2016-04-22 14:26:15 +02:00
Thomas Pelletier
288bc57940
Better logging for parser tests ( #65 )
...
* Better logging for parser tests
* Add spew to tests deps list
2016-04-22 11:01:31 +02:00
Thomas Pelletier
d6a90e60ed
Fix #52 : query matcher doesn't handle arrays tables
...
Also improve coverage of query matcher.
2016-03-16 09:56:04 -07:00
Thomas Pelletier
2df083520a
Fix support for CRLF line ending
2016-02-19 14:12:13 +01:00
Thomas Pelletier
f963bc320f
Generic input
...
Fixes #47
2016-01-31 16:54:40 +01:00
Thomas Pelletier
6d743bb19f
Improve error checking on number parsing
2015-12-01 14:38:33 +01:00
Thomas Pelletier
a6c6ad1f5f
Don't crash when assigning group array to array
2015-12-01 13:56:31 +01:00
Thomas Pelletier
7d69e5a5c5
Tests for erroneous inline tables
2015-09-09 17:40:27 +01:00
Thomas Pelletier
07d0c2e4d3
Merge branch 'master' into pelletier/inline-tables
2015-09-09 17:35:03 +01:00