Skip to content

Conversation

vmfhrmfoaj
Copy link

Fix for inline table, float, string and multi-line string.

- `parse-string` should convert following string to `{"name" {"first" "Tom", "last" "Preston-Werner"}, "point" {"x" 1, "y" 2}}`.
  ```toml
  [table.inline]
  name = { first = "Tom", last = "Preston-Werner" }
  point = { x = 1, y = 2 }
  ```

- fix for timestmap

- fix typo error: "Neil" => "Nail"
`process` method for `inline table` convert inline table form to standard table form. and the conversion is processed sequentially.
`process` method for `standard table` include values up to the next table or the end of input.

For example:
```clojure
([:inline-table "tb_a" [:inline-table "val" 10]] [:inline-table "tb_b" [:inline-table "val" 20]])  ; (A)
([:std-table ["tb_a"]] [:keyval "val" 10]        [:inline-table "tb_b" [:inline-table "val" 20]])  ; (B)
```

So, (B) means "tb_b" is included into "tb_a".
I fix the `process` method for `inline table` to avoid the problem.
```clojure
(toml-parser "a = -0.1")
;;=> [:toml [:keyval [:key "a"] [:float [:dec-int "-" "0"] "." "1"]]]
;;                                      ^^^^^^^^^^^^^^^^^^
;;                                      This part will be converted to 0
```

I think `toml-transform` transforms the parsed data from innermost to outermost.
So, `float` transformer will get "0.1" instead of "-0.1". Because, `dec-int` transformer converted "-0" to 0.
I fixed grammar to remove `:dec-int` tag.
I think need to convert some escaped characters (e.g. '\t', '\n' and so on) to some corresponding characters (e.g. tab, newline and so on).

I checked other implementations by written with Go and Node.js:
- https://github.com/naoina/toml (Golang, v0.4)
- https://github.com/komkom/toml (Golang, v1.0)
- https://www.npmjs.com/package/@iarna/toml (Node.js, v0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant