Skip to content

Commit e39d2a2

Browse files
authored
Create stdlib/toml.jou, a TOML parser (#1260)
1 parent 135455c commit e39d2a2

File tree

13 files changed

+2710
-4
lines changed

13 files changed

+2710
-4
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ jobs:
5555
- name: "Run hello world with valgrind"
5656
run: ./runtests.sh --verbose --jou-flags "${{ matrix.params.opt-level }}" --valgrind hello
5757
- run: ./doctest.sh
58+
- run: tests/toml/run.sh --jou-flags "${{ matrix.params.opt-level }}"

.github/workflows/valgrind.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
- run: LLVM_CONFIG=llvm-config-${{ matrix.params.llvm-version }} make
7171
- name: "Test compiler with valgrind"
7272
run: ./runtests.sh --verbose --valgrind --jou-flags "${{ matrix.params.opt-level }}"
73+
- run: tests/toml/run.sh --valgrind --jou-flags "${{ matrix.params.opt-level }}"
7374

7475
# Please keep in sync with macos.yml and linux-aarch64.yml
7576
create-issue-on-failure:

doc/json-building.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ I get `12,34` in the JSON instead of the expected `12.34`.
132132
Some libraries (e.g. Gtk) call `setlocale()` automatically,
133133
and that can also cause this problem.
134134
Please [create an issue on GitHub](https://github.com/Akuli/jou/issues/new) if you run into this.
135-
There is a similar problem with [parsing JSON](json-parsing.md#notes-about-numbers).
135+
There is a similar problem with [parsing JSON](json-parsing.md#notes-about-numbers)
136+
and [parsing TOML](toml.md#notes-about-numbers).
136137

137138

138139
## Notes about strings

doc/json-parsing.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def main() -> int:
6767
| `json_object_value(json)` | `byte*` (JSON) | pointer into value in `json` or NULL |
6868
| `json_get(json, key)` | `byte*` (JSON) | pointer into value in `json` or NULL |
6969
| `json_to_double(json)` | `double` | value in `json` or NaN |
70-
| `json_to_string(json)` | `byte*` (needs `free()`) | string from `json` or NULL |
70+
| `json_to_string(json)` | `byte*` (needs `free()`) | new copy of string in `json` or NULL |
7171
| `json_equals_string(json, s)` | `bool` | `True` if `json` points at `s` as a JSON string |
7272
| `json_is_true(json)` | `bool` | `True` if `json` points at a JSON `true` |
7373
| `json_is_false(json)` | `bool` | `True` if `json` points at a JSON `false` |
@@ -137,6 +137,7 @@ Once you have found the value you want, you can use these functions to parse it:
137137
`json_is_null("null")` returns `True` but `json_is_null(NULL)` returns `False`.
138138
- `json_to_double(json: byte*) -> double` gets a `double` value from a JSON number.
139139
If `json` doesn't start with a JSON number, this function returns NaN.
140+
To check for NaN, you can use the `isnan()` function in [stdlib/math.jou](../stdlib/math.jou).
140141
See also [the notes about numbers below](#notes-about-numbers).
141142
- `json_to_string(json: byte*) -> byte*` parses a string from JSON
142143
and returns it as `\0`-terminated UTF-8 (that is, a typical Jou string).
@@ -300,7 +301,8 @@ and `atof()` does not understand the `.34` part of the number because it's expec
300301
Some libraries (e.g. Gtk) call `setlocale()` automatically,
301302
and that can also cause this problem.
302303
Please [create an issue on GitHub](https://github.com/Akuli/jou/issues/new) if you run into this.
303-
There is a similar problem with [building JSON](json-building.md#notes-about-numbers).
304+
There is a similar problem with [building JSON](json-building.md#notes-about-numbers)
305+
and [parsing TOML](toml.md#notes-about-numbers).
304306
305307
306308
## Notes about strings

0 commit comments

Comments
 (0)