Commit Graph

75 Commits

Author SHA1 Message Date
ToruNiina
d90ffb63c6 Merge branch 'master' into allow-deeper-table-before 2019-03-05 23:27:11 +09:00
ToruNiina
b0ed122214 fix: allow deeper table appeared before
allow the following toml file.
```toml
[a.b.c]
d = 10
[a]
e = 2.718
```
2019-03-05 23:25:25 +09:00
ToruNiina
2accc9d22c fix: diagnose, but not throw for unicode error
in 2.0.x and 2.1.0, README says "it shows warning" for invalid unicode
codepoints. So far, this library just show an error message in stderr
for this case. It is not good to change the behavior fatal in the next
minor release, 2.1.1, that includes patches and improved error msgs.
I will make it throw syntax_error after 2.2.0 for invalid unicode
codepoints. For now, I will keep it to be "warning".
2019-03-03 18:56:45 +09:00
ToruNiina
ae793fb631 feat: improve error message for invalid array 2019-03-02 17:56:16 +09:00
ToruNiina
7f870d5861 fix: diagnose invalid UTF-8 codepoints 2019-03-02 01:57:05 +09:00
ToruNiina
536b23dc84 fix: allow empty table in the middle of a file 2019-03-01 22:53:16 +09:00
ToruNiina
0c9806e99f fix: diagnose key after [table.key] pattern
the following is not a valid toml format.
```
[table] key = "value"
```
this commit enables to diagnose that pattern.
2019-03-01 22:37:52 +09:00
ToruNiina
e929d2f00f fix: allow empty input file (to be an empty table) 2019-02-27 12:30:57 +09:00
ToruNiina
d0726db473 chore: merge branch master into err-msg-dotted-key 2019-02-27 01:26:36 +09:00
ToruNiina
73ba6b385f feat: use key-region to represent table
use x.y.z = 42
    ~~~ here as the region of the table `x.y`
2019-02-27 01:02:39 +09:00
ToruNiina
30d1639aa4 refactor: return region info from parse_kvpair 2019-02-27 00:21:05 +09:00
Quentin Khan
d82814fc86 Add location to error string in parse_* functions 2019-02-26 14:56:58 +01:00
ToruNiina
679b365cf7 feat: get region info when parsing keys
Error messages related to dotted keys looks weird. like:
 1 | a.b.c = 42
   |         ~~ in this table
The underlined token is not a table. This should be like the following.
 1 | a.b.c = 42
   | ~~~ in this table
To implement this, the region information is needed when the keys are
read. This commit add this functionality, though currently the region
information is not used yet.
2019-02-26 00:17:28 +09:00
ToruNiina
dd9319245e fix: open file as binary-mode #16
to avoid inconsistency between file size (obtained by tellg) and the
size of the actual contents that would be read later
2019-02-13 19:18:09 +09:00
Toru Niina
b5b8830c29
Merge pull request #17 from ToruNiina/hotfix
fix the error with BOM and end of file w/o newline
2018-12-24 16:37:10 +09:00
ToruNiina
11c7ee4501 fix the case of file w/o newline at the end
toml::parse failed with the file that contains whitespace or comment at
the end of file without newline. this commit fixes the error.
2018-12-24 16:00:33 +09:00
ToruNiina
d24a188d4c fix the error while reading BOM.
remove possible UB because of the use-after-move.
2018-12-24 15:06:26 +09:00
ToruNiina
7c03c446fe speedup by removing needless format_underline
drastical speedup for long toml files
2018-12-23 15:22:12 +09:00
ToruNiina
9c95992dad fix error message for empty value 2018-12-22 17:44:09 +09:00
ToruNiina
c63ac7e435 detect syntax_error; appending array-of-tables
toml file like the following is explicitly prohibited.
a = [{b = 1}]
[[a]]
b = 2
this commit detects this kind of syntax-error while parsing toml file
2018-12-22 17:07:06 +09:00
ToruNiina
fec49aaaa3 fix error message: add missing spaces 2018-12-22 17:06:36 +09:00
ToruNiina
0c08b9e940 fix typo 2018-12-15 22:02:46 +09:00
ToruNiina
fd21d5dd95 add simplest copyright notice 2018-12-13 20:44:10 +09:00
ToruNiina
57de57a1de improve error message for empty value 2018-12-13 20:37:40 +09:00
ToruNiina
e86777d19c improve error message for conflicting tables 2018-12-13 20:17:57 +09:00
ToruNiina
e79069cc47 enable to show err msg for invalid insertion
like, with the following (invalid) toml file

> a.b = "value"
> a.b.c = 42

The error message becomes

> terminate called after throwing an instance of 'toml::syntax_error'
>   what():  [error] toml::insert_value: target (a.b) is neither table nor
> an array of tables
>  --> example.toml
>  1 | a.b = "value"
>    |       ~~~~~~~ actual type is string
>  ...
>  2 | a.b.c = 42
>    |         ~~ inserting this
2018-12-13 17:09:38 +09:00
ToruNiina
acc7b7870f remove format_error_for_value and add get_region instead
it is convenient to have get_region function that can access region_info
in toml::value. get_region is placed in toml::detail and made friend of
toml::value because I don't want to make toml::value::region_info public
and keep it internal use only.
2018-12-13 16:13:05 +09:00
ToruNiina
47cd6f5a41 remove redundant error message 2018-12-12 23:17:28 +09:00
ToruNiina
5aae0b17c8 change error message; require unicode codepoint
before this, it recommends the range that can be represented by utf-8
but the range of valid unicode codepoint is narrower than that. for
error message, it is good to recommend valid unicode codepoint.
2018-12-12 19:14:27 +09:00
ToruNiina
0f83ee6039 change temporaly loc from token to copy of loc
location constructed from token string does not has correct line number
information. to show an informative error message about UTF-8 and escape
sequences, parse_(ml_)basic_string requires those information that can
only be given from root location<Container>.
2018-12-12 19:12:23 +09:00
ToruNiina
879b7d3bff improve format of error message for utf-8 2018-12-12 19:01:22 +09:00
ToruNiina
bcaf5baf88 fix parse_array_of_table_key
allow whitespace before and after [[ and ]] (like, [[ a.b ]])
2018-12-12 12:14:11 +09:00
ToruNiina
a1a81089c5 skip whitespace before/inside/after dotted-keys 2018-12-12 01:30:47 +09:00
ToruNiina
d7bba10fa3 improve error message in parse_key_value_pair 2018-12-11 22:21:22 +09:00
ToruNiina
247bcb0714 show error message for inhomogenous array 2018-12-11 22:17:28 +09:00
ToruNiina
27b9334f10 skip BOM if exists 2018-12-11 21:40:48 +09:00
ToruNiina
4e57c5f5df improve error message for invalid line
like a = 12 = true, newline is expected after 12
2018-12-10 21:43:02 +09:00
ToruNiina
ff83a6a477 remove redundant part of error messages 2018-12-10 21:42:56 +09:00
ToruNiina
ff19c9f492 add corresponding region to each value 2018-12-10 15:57:17 +09:00
ToruNiina
8e18aa9b16 add toml::parse 2018-12-10 00:14:46 +09:00
ToruNiina
ed155a5040 remove help msgs in parse_value
because the error message becomes too long
2018-12-09 21:54:47 +09:00
ToruNiina
cf03a08632 re-write parser using result and new value
wip.
2018-12-09 19:32:30 +09:00
ToruNiina
6c0a12148b add result<T, E> struct to handle errors
aiming later updates and refactoring of parsers
2018-12-02 18:01:37 +09:00
ToruNiina
5aeb6f24df change exception type #8; iterator may be invalid 2017-12-24 11:02:32 +09:00
ToruNiina
3f1b431ee2 add missing inline specifier #7 2017-12-15 21:39:38 +09:00
ToruNiina
d1fd42ff7e output line number if error occured 2017-06-17 19:05:24 +09:00
ToruNiina
80adda8184 open file with binary mode 2017-05-17 14:12:19 +09:00
ToruNiina
2c92142d5c restore parser and test 2017-05-17 14:07:34 +09:00
ToruNiina
d77ec7dc88 restore old parse function 2017-05-17 13:21:32 +09:00
ToruNiina
430940f766 fix typos 2017-05-17 13:12:21 +09:00