Skip to content

Commit

Permalink
fix: trailing whitespaces are allowed for local_time (#3)
Browse files Browse the repository at this point in the history
Input:

(each `·` indicates a whitespace)

```toml
valid·=·1979-05-27·
```

Output:

```
# before

(file
  (ERROR
    (key)))

# after

(file
  (pair
    (key) (local_date)))
```
  • Loading branch information
ikatyang authored Aug 21, 2019
1 parent 9bdd88e commit 752419c
Show file tree
Hide file tree
Showing 7 changed files with 2,064 additions and 2,349 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[corpus/*]
trim_trailing_whitespace = false
19 changes: 15 additions & 4 deletions corpus/custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ invalid2 = 1979-05-27 T 07:32:00 Z

(file
(ERROR
(key) (ERROR) (local_time) (local_time)
(key) (local_date) (local_time) (local_time)
)
)

Expand All @@ -78,11 +78,22 @@ invalid2 = 1979-05-27 T 07:32:00
--------------------------------------------------------------------------------

(file
(pair
(key) (ERROR) (local_time)
(ERROR
(key) (local_date) (local_time) (local_time)
)
)

================================================================================
VALID - local date - trailing whitespaces are allowed
================================================================================

valid = 1979-05-27

--------------------------------------------------------------------------------

(file
(pair
(key) (ERROR) (local_time)
(key) (local_date)
)
)

Expand Down
14 changes: 5 additions & 9 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,14 @@ module.exports = grammar({
boolean: $ => /true|false/,

offset_date_time: $ =>
seq(
concatRegex(
rfc3339_date,
token.immediate(rfc3339_delimiter),
token.immediate(rfc3339_time),
token.immediate(rfc3339_offset)
rfc3339_delimiter,
rfc3339_time,
rfc3339_offset
),
local_date_time: $ =>
seq(
rfc3339_date,
token.immediate(rfc3339_delimiter),
token.immediate(rfc3339_time)
),
concatRegex(rfc3339_date, rfc3339_delimiter, rfc3339_time),
local_date: $ => rfc3339_date,
local_time: $ => rfc3339_time,

Expand Down
53 changes: 4 additions & 49 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 752419c

Please sign in to comment.